Re: Pressuring GC to give up clean up memory.

Tech-Archive recommends: Fix windows errors by optimizing your registry



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.


.



Relevant Pages

  • Re: ``shutdown -p now not working in 5.4 STABLE
    ... but I have a system running 5.4-STABLE as of ... Other than the lack of a NVIDIA memory controller (pci0 ... CPU: AMD AthlonXP 2700+ ... acpi0: on motherboard ...
    (freebsd-stable)
  • Re: Pressuring GC to give up clean up memory.
    ... triggered when your app makes an allocation (well, when you allocate memory ... if your app is sitting idle while you are applying memory pressure from ... memory unless pressured to do so (e.g. system running out of memory). ...
    (microsoft.public.dotnet.languages.csharp)
  • Pressuring GC to give up clean 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. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Memory usage
    ... >> as insufficient memory. ... >> program file you've double clicked on. ... > The problem turned out to be the system running out of space in the shared ... Too large a VIRTUALADDRESSLIMIT setting, ...
    (comp.os.os2.misc)
  • Re: Pressuring GC to give up clean up memory.
    ... Is the number you are seeing the only concern, or is the memory that is ... being consumed by your app having a measurable effect on other applications ... memory unless pressured to do so (e.g. system running out of memory). ...
    (microsoft.public.dotnet.languages.csharp)