Re: Pressuring GC to give up clean up memory.
- From: Frank Rizzo <none@xxxxxxxx>
- Date: Mon, 14 May 2007 14:57:22 -0700
Alun Harford wrote:
Frank Rizzo wrote:I have an app ( referenced in thread news://msnews.microsoft.com:119/OPTBaFDlHHA.3280@xxxxxxxxxxxxxxxxxxxx ) that won't give up memory. Several people stated that GC won't clean up memory unless pressured to do so (e.g. system running out of memory). So I wrote a quickie app to gobble up memory 100mb at a time, but I still don't see anything giving up memory (including other .NET apps).
I see the commit charge going up and go past the physical memory, but still no dice.
Did I write it correctly?
Well the garbage collector won't clear up memory if there's a reference to it.
while (true)
{
count++;
// allocate 1 MB
Byte[] K = new byte[1024 * 1024];
lst.Add(K);
You're adding the byte[] to the list, so there's still a reference around.
If you leave out the last line, GC will give up memory when the system needs it.
No, no, no. I think everyone misunderstood the point of this code. This code is a standalone console app that is meant to gobble up memory in order to induce other .NET applications to start its garbage collection.
.
- Follow-Ups:
- Re: Pressuring GC to give up clean up memory.
- From: Steven Cheng[MSFT]
- Re: Pressuring GC to give up clean up memory.
- References:
- Pressuring GC to give up clean up memory.
- From: Frank Rizzo
- Re: Pressuring GC to give up clean up memory.
- From: Alun Harford
- Pressuring GC to give up clean up memory.
- Prev by Date: Re: Pressuring GC to give up clean up memory.
- Next by Date: Re: List<> of struct with property. Cannot change value of property. why?
- Previous by thread: Re: Pressuring GC to give up clean up memory.
- Next by thread: Re: Pressuring GC to give up clean up memory.
- Index(es):
Relevant Pages
|