Is .NET memory management really this bad ?

Is .NET memory management really this bad ?

Post by Mike Oliszewsk » Fri, 22 Nov 2002 05:03:05



Observe the following test application:

using System;
using System.Windows.Forms;

namespace XmlTest2
{
  class Class1
  {
    static void Main(string[] args)
    {
      String MyString;
      MessageBox.Show(System.GC.GetTotalMemory(true).ToString());
      MyString = new String('x',125000000);
      MessageBox.Show(System.GC.GetTotalMemory(true).ToString());
      MyString = new String('x',5);
      MessageBox.Show(System.GC.GetTotalMemory(true).ToString());
   }
  }

Quote:}

Execution of the program shows the following:

Box 1:  43,280
Box 2:  250,049,574
Box 3:  49,584

Looks great.  Now look in task manager and you will see the application
memory usage is still at 251M... it didn't go down.  Run this application
twice and you see my nightmare  Note: I have 512M RAM on my system.

The application run only once takes under one second to allocate the 250M,
process it through to the third Box where the ram has been released, and
then run another instance of the app.  This time it takes 45 seconds to
allocate the buffer because it has to virtualize the first instance to
disk... .NET freed the memory internally but didn't release it back to
Windows.

PLEASE tell me there is a way to get .NET to release the memory.  Our server
application which is running about 20 processes is DOA with this memory
handling.

 
 
 

Is .NET memory management really this bad ?

Post by Joe Fese » Fri, 22 Nov 2002 06:05:41


The average object in .NET is not allocated at 125mb.

Smaller objects will clean themselves up when needed.

Joe


Quote:> Observe the following test application:

> using System;
> using System.Windows.Forms;

> namespace XmlTest2
> {
>   class Class1
>   {
>     static void Main(string[] args)
>     {
>       String MyString;
>       MessageBox.Show(System.GC.GetTotalMemory(true).ToString());
>       MyString = new String('x',125000000);
>       MessageBox.Show(System.GC.GetTotalMemory(true).ToString());
>       MyString = new String('x',5);
>       MessageBox.Show(System.GC.GetTotalMemory(true).ToString());
>    }
>   }
> }

> Execution of the program shows the following:

> Box 1:  43,280
> Box 2:  250,049,574
> Box 3:  49,584

> Looks great.  Now look in task manager and you will see the application
> memory usage is still at 251M... it didn't go down.  Run this application
> twice and you see my nightmare  Note: I have 512M RAM on my system.

> The application run only once takes under one second to allocate the 250M,
> process it through to the third Box where the ram has been released, and
> then run another instance of the app.  This time it takes 45 seconds to
> allocate the buffer because it has to virtualize the first instance to
> disk... .NET freed the memory internally but didn't release it back to
> Windows.

> PLEASE tell me there is a way to get .NET to release the memory.  Our
server
> application which is running about 20 processes is DOA with this memory
> handling.


 
 
 

Is .NET memory management really this bad ?

Post by Christoph Schittk » Fri, 22 Nov 2002 07:27:54


Sounds like the large object heap bug which causes the garbage collection to
hold on to objects larger than a certain threshold, but I forget what
exactly the limit is. Supposedly it's fixed in V1.1, which is currently
available as a public beta.

HTH,
--
Christoph Schittko
Software Architect


> The average object in .NET is not allocated at 125mb.

> Smaller objects will clean themselves up when needed.

> Joe



> > Observe the following test application:

> > using System;
> > using System.Windows.Forms;

> > namespace XmlTest2
> > {
> >   class Class1
> >   {
> >     static void Main(string[] args)
> >     {
> >       String MyString;
> >       MessageBox.Show(System.GC.GetTotalMemory(true).ToString());
> >       MyString = new String('x',125000000);
> >       MessageBox.Show(System.GC.GetTotalMemory(true).ToString());
> >       MyString = new String('x',5);
> >       MessageBox.Show(System.GC.GetTotalMemory(true).ToString());
> >    }
> >   }
> > }

> > Execution of the program shows the following:

> > Box 1:  43,280
> > Box 2:  250,049,574
> > Box 3:  49,584

> > Looks great.  Now look in task manager and you will see the application
> > memory usage is still at 251M... it didn't go down.  Run this
application
> > twice and you see my nightmare  Note: I have 512M RAM on my system.

> > The application run only once takes under one second to allocate the
250M,
> > process it through to the third Box where the ram has been released, and
> > then run another instance of the app.  This time it takes 45 seconds to
> > allocate the buffer because it has to virtualize the first instance to
> > disk... .NET freed the memory internally but didn't release it back to
> > Windows.

> > PLEASE tell me there is a way to get .NET to release the memory.  Our
> server
> > application which is running about 20 processes is DOA with this memory
> > handling.

 
 
 

1. Memory management for by .NET Application

Hello all,
Does anybody hasobserved that when we run the .NET application, in the
Windows's Task
Manager (under process's tab), it shows memory size of application very
large but
when we first time minimize the application and maximize it  then the size
of the apllication is reduced by half.
What does the application gain when first time we minimize it ? Which memory
application
acquires when we run it & which memory it releases when we minimize
application
first time?

Thanks in advance,

-Regards,
Dinesh

2. windows installer

3. Visual studio .net memory management problems

4. Why clicking on a nav button brings up a new browser window?

5. TreeView Icons Look Really Bad

6. Advice? Good ISDN TA?

7. Am I really this thick??

8. Big Time Help Needed!

9. I am really sick of VS.net

10. memory leak not really real???

11. Essay: Why direct memory access is a bad thing.

12. Am I causing a memory leak?

13. Memory Management