Re: Tracking a memory leak.
- From: "Willy Denoyette [MVP]" <willy.denoyette@xxxxxxxxxx>
- Date: Sat, 12 May 2007 11:08:19 +0200
"Frank Rizzo" <none@xxxxxxxx> wrote in message news:OPTBaFDlHHA.3280@xxxxxxxxxxxxxxxxxxxxxxx
I have an object tree that is pretty gigantic and it holds about 100mb of data. When I set the top object to null, I expect that the .NET framework will clean up the memory at some point. However, I am looking at the Task Manager and I don't see the MemUsage column decreasing even after an hour or two. I know that TaskManager may not be the best place to see what is the true way to gauge memory usage and/or presense of memory leaks. So I am looking for a pointer on what I should use to see whether setting an object to null really will at some point free up memory.
Regards
You should take a look at the "CLR Memory performance" counters, notably the Gen0, 1, 2 and Large Object heap counters are of interest.
What is shown in Taskman is the size of your process Working Set or the Private Bytes (depending the counter you are looking at), the GC allocates and de-allocates object space from a Private Heap holding the above generational heaps, this Private Heap,w which is part of the Private Bytes and the Working Set, grows, by requesting new segments from the OS, whenever the Generational heap 0 is full and the GC needs more space to allocate objects from.
However, this heap will not necessarily decrease when objects are getting GC'd, all the GC does is free the object space and compact the generational heaps (0, or 0 and 1, or 0, 1 and 2).
The CLR "Memory Allocator" de-commits (after compactation) the pages that were previously occupied by object data, and returns the Segment to the OS when *all pages* from that segment (but not the default segments) are decommited.
Note that pinned objects can spoil the party, as these cannot move to another segment and as such prevents the Segment to become de-committed completely. Another thing that you need to watch for is the LOH, as this heap is never compacted, keeping objects alive in one of the possible extra segment for this LOH, will prevent the segment to return to the OS.
Willy.
.
- References:
- Tracking a memory leak.
- From: Frank Rizzo
- Tracking a memory leak.
- Prev by Date: Can I remove text from a StringWriter ?
- Next by Date: Re: IStream interface
- Previous by thread: Re: Tracking a memory leak.
- Next by thread: Re: Tracking a memory leak.
- Index(es):
Relevant Pages
|