결정 성을 높이려면 메모리가 어디에서 끝나는 지 확인하기 위해 통합 테스트를 작성해야합니다. WMemoryProfiler으로 지금 할 수 있습니다.먼저 1500x1500 크기로 이미지를로드하고 모든 것을 정리 한 다음 모든 오브젝트를 알려진 것으로 표시합니다. 그런 다음 큰 이미지를 재배치하고 할당 된 새로운 객체를 확인하고 얼마나 많은 객체가 있고 객체를 소유하고 있는지를 예리하게 관찰합니다.
많은 외부 모듈이 사용된다고합니다. 아마도 당신은 현명하지 못한 메모리 사용으로 인해 그 중 일부를 버리고 더 나은 것으로 대체해야 할 것입니다. 이제 확인할 수 있습니다.
한계에 도달 한 경우 이미지를로드 할 수 있고 개발자와 플러그인이 IEnumerable<Image>
과 같은 지연 구조를 지원하는 경우 이미지를로드 할 때 이미지를로드 할 시간과 길이를 결정할 수 있습니다 메모리를 확보하는 데 도움이되는 참조를 제거 할 때까지 캐시에 저장하십시오.
[Test]
public void InstanceTracking()
{
using (var dumper = new MemoryDumper()) // if you have problems use to see the debugger windows true,true))
{
TestWith1500x1500();
dumper.MarkCurrentObjects();
TestWith3000x3000();
ILookup<Type, object> newObjects = dumper.GetNewObjects()
.ToLookup(x => x.GetType());
// here we do find out which objects are holding most of the memory
MemoryStatistics statOld = dumper.GetMemoryStatistics();
foreach (var typeInfo in statOld.ManagedHeapStats
.OrderByDescending(x => x.Value.Count))
{
Console.WriteLine("Type {0} has {1} instances of total size {2:N0} bytes",
typeInfo.Key,
typeInfo.Value.Count,
typeInfo.Value.TotalSize);
}
// then check with the info from above who is holding the most interesting new objects.
Console.WriteLine("New Strings:"); // just an example perhaps you should have a look at the images.
foreach (var newStr in newObjects[typeof(string)])
{
Console.WriteLine("Str: {0}", newStr);
}
}
}
얼마나 많은 사용자가 한계에 부딪 쳤습니까? – Limey
나는 그 질문을 이해하지 못한다. 이미지는 1500x1500 픽셀이며 모두 잘 작동합니다. 비디오 스트림의 소스 이미지 해상도가 3500x3500이면 동일한 코드 및 동일한 절차로 응용 프로그램이 메모리 예외와 충돌합니다. 그러나 컴퓨터는 3GB 이상의 RAM을 사용할 수 있으며 무료입니다. – Nasenbaer
[ANTS 메모리 프로파일 러] (http://www.red-gate.com/products/dotnet-development/ants-memory-profiler/)와 같이 _memory_ 프로파일 러 (즉, _performance_ 프로파일 러가 아님)를 사용할 것입니다. –