ANTS Memory Profiler 11

Understanding ANTS Memory Profiler

Recommendations

Finding memory problems requires some detective work. To use ANTS Memory Profiler, you need the following:

  1. Good knowledge of your code.
  2. An understanding of how .NET memory management works.
  3. (Ideally) An idea of where in your code your problem might be occurring.

If you have a leak in managed memory, it's likely that you're leaking more than one object:

  • The object kept in memory because of this leak.
  • Objects in classes from the CLR itself, referenced by the leaked object.

For example, if the leaked object contains text, at least one System.String object will also be kept in memory. Your object may only be a few bytes large, but it may be holding a significant amount of memory in classes from the CLR.

Conversely, this means that when you are looking for leaked objects in your code using ANTS Memory Profiler, it is often useful to start by looking at these classes inherited from the CLR, rather than starting from your own classes.

Remember also that no program can decide whether or not an object is a leak, because it depends on the nature of the program you are profiling. If a large number of strings are kept in memory for a long time in word processing software, this may not be an indicator of a problem. However, if strings from a dialog box that has been closed are kept in memory in a graphics program, this could be a good place to start the investigation. Ultimately, therefore, you will need to use knowledge of your code to interpret the information shown in ANTS Memory Profiler.


Didn't find what you were looking for?