My app was using 150mb of memory not to long ago, now it is at 286mb. It slowly rises so i must be forgetting to dispose something. This isnt much of a problem for me since i have 4gb but i want to send this to others who have only 1gb of ram. other then going through the code line by line how can i find objects that need to be disposed of or just generally large objects?
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
- How to know full paths to DLL's from .csproj f
Here are couple of tricks using the ANTS Memory Profiler to help find undisposed objects and fix the leaks.
The ANTS Memory profiler allows a filter to be set that show just objects that contain a Dispose() method. Turn this on, and you'll be given a list of live objects that have not been disposed.
While finding undisposed objects is useful, even more useful is knowing why these objects are not being disposed. Finding where these undisposed objects are created goes a long way to finding the reason for the leak. If you are able to change the code of the leaking object, a useful trick is to introduce a field to hold a stacktrace, and populate this field at the time of object construction. Then because the ANTS memory profiler allows you to inspect fields of objects, you can simply read off the stacktrace as it was at the time the leaking objects were created. This will give you a strong clue as to who the owner of the leaking objects should be, and how they should go about calling Dispose on the objects they are responsible for.
heres a method i use:
http://www.codeproject.com/KB/dotnet/Memory_Leak_Detection.aspx