Wednesday, January 17, 2007

Identifying Memory Leaks in .NET Apps

Applies to .NET 1.0, 1.1 and 2.0.

This information has been extracted from the MSDN article, Identify and Prevent Memory Leaks in Managed Code, by James Kovacs.

Useful PerfMon Counters

Process/[Private Bytes]
Reports all memory that is exclusively allocated for a process and can't be shared with other processes on the system.

.NET CLR Memory/[# Bytes in All Heaps]
Reports the combined total size of the Gen0, Gen1, Gen2 and large object heaps.

.NET LocksAndThreads/[# of current logical Threads]
Reports the number of logical threads in an AppDomain.

Interpreting the Results

The following problems may be identified:

  • Thread Stack Leaks - [# of current logical Threads] increases unexpectedly

  • Unmanaged Memory Leaks - [Private Bytes] increases but [# Bytes in All Heaps] remains stable

  • Managed Memory "Leaks" - [Private Bytes] increases AND [# Bytes in All Heaps] increases

For detailed explanations on these, please read the MSDN article, Identify and Prevent Memory Leaks in Managed Code.

1 comment:

Anonymous said...
This comment has been removed by a blog administrator.
Powered By Blogger