Memory management for by .NET Application

Memory management for by .NET Application

Post by Dinesh Jai » Mon, 05 May 2003 00:08:16



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

 
 
 

Memory management for by .NET Application

Post by Richard Grimes [MVP » Mon, 05 May 2003 01:16:08



Quote:> 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?

This is typical of Windows apps, but is amplified by .NET. When the app
starts its DLLs are loaded too and these are paged into physical memory.
When you minimize the app all the DLLs are paged to virtual memory (disk),
and when you restore only those DLLs that are actually needed at that point
in time are paged back into physical memory. Of course, as you run the app
you'll find that the other DLLs maybe paged back into physical memory.

There's more details here
http://www.windevnet.com/documents/s=7446/win1044570813618/

Richard
--


 
 
 

Memory management for by .NET Application

Post by Dinesh Jai » Wed, 07 May 2003 15:41:22


Thanks Mr. Richard Grimes , that helped a lot.
Now I am a bit clear about the memory management.
Once again Thanks a lot.

-Regards,
Dinesh





> > 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?

> This is typical of Windows apps, but is amplified by .NET. When the app
> starts its DLLs are loaded too and these are paged into physical memory.
> When you minimize the app all the DLLs are paged to virtual memory (disk),
> and when you restore only those DLLs that are actually needed at that
point
> in time are paged back into physical memory. Of course, as you run the app
> you'll find that the other DLLs maybe paged back into physical memory.

> There's more details here
> http://www.windevnet.com/documents/s=7446/win1044570813618/

> Richard
> --


 
 
 

1. Is .NET memory management really this bad ?

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.

2. Many domains, stop logon to some domains

3. Visual studio .net memory management problems

4. Nokia 9000 Doucment corruption

5. Windows Applications Lead Developer (.Net) - Investment Management - Boston, MA Area - Excellent Package

6. Prob. w/ IBM internet news read!!!

7. Exception Management Application Blocks for .NET bug?

8. Memory Management

9. Windows Memory Management

10. ADO DOTNET memory management?

11. Memory management