Click here to Skip to main content
15,914,109 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
GeneralRe: Please help - COM Interop Pin
Christian Graus7-Jul-05 13:11
protectorChristian Graus7-Jul-05 13:11 
GeneralRe: Please help - COM Interop Pin
Alomgir Miah11-Jul-05 8:29
Alomgir Miah11-Jul-05 8:29 
GeneralC1083 Error: Including .h files Pin
Anonymous6-Jul-05 7:53
Anonymous6-Jul-05 7:53 
GeneralRe: C1083 Error: Including .h files - Nevermind Pin
Anonymous6-Jul-05 8:12
Anonymous6-Jul-05 8:12 
Generalstandalone manifest Pin
CoolAmir5-Jul-05 21:26
CoolAmir5-Jul-05 21:26 
GeneralRe: standalone manifest Pin
MoustafaS7-Jul-05 2:50
MoustafaS7-Jul-05 2:50 
General.Net Memory Management Issue Pin
ge_anand5-Jul-05 7:49
ge_anand5-Jul-05 7:49 
GeneralRe: .Net Memory Management Issue Pin
Dave Kreskowiak5-Jul-05 9:35
mveDave Kreskowiak5-Jul-05 9:35 
Edwin Anand wrote:
and check for the memory status in Task Manager

First, do not ever do this with Task Manager. It will never give you how much memory your managed .NET application is actually using. Use Performance Monitor and the .NET Framework counters to do this.

Here's the simplified explanation:

What you're seeing in Task Manager is how much memory has been reserved for your applications MANAGED memory heap, not how much your app is using! The Managed Heap is a nice size block of memory, reserved for your applications use, created out a block of unmanaged memory. There's a reason why the .NET Framework runtime environment is called a virtual machine, just like Java's runtime environment.

The .NET Framework memory manager will set aside a block of unmanaged memory (what you're seeing in Task Manager) and create the Managed memory heaps in it. When you application creates an object, it's created in either the Small Object Heap or the Large Object Heap, depending on the objects initial size. Since this object has been created inside the Managed Heap, there's no effect on what you see in Task Manager since it only looks at unmanaged memory. When the object goes out of scope, the memory gets released back to the Managed Heap, not the unmanaged.

Now, the numbers you see in Task Manager DO change during your applications execution. Why? There's a couple of reasons.

The .NET Memory Manager likes to keep a cushion so the next time you allocate an object, you don't have to wait for the memory manager to grab another block of unmanaged memory and add it to the managed heap, then allocate your object in it.

But, the memory manager also has to balance what it allocates against what Windows wants for other buffers and processes. The memory manager, when it thinks there is too much unmanaged memory allocated to your app, will release managed memory back to the unmanaged heaps. This will happen when you deallocate an object or when your applications data gets swapped to disk and back to RAM.

To see a little demo of this, try starting your application and watch what happens in Task Manager. You'll start out with a good size chunk of memory (roughly 15-20 Meg on startup). Now minimize your application and watch what happens in Task Manager. It drops considerably because your app just got swapped to disk. Restore your app so you can see it again and your app's memory consumption will increase, but not as high as when you started your app. Since your application didn't need some data and free space, the memory was either not swapped back to RAM or was released back to the unmanaged pool.



RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

GeneralRe: .Net Memory Management Issue Pin
[Marc]5-Jul-05 11:10
[Marc]5-Jul-05 11:10 
GeneralRe: .Net Memory Management Issue Pin
S. Senthil Kumar6-Jul-05 6:57
S. Senthil Kumar6-Jul-05 6:57 
GeneralRe: .Net Memory Management Issue Pin
[Marc]6-Jul-05 10:15
[Marc]6-Jul-05 10:15 
GeneralRe: .Net Memory Management Issue Pin
ge_anand6-Jul-05 20:26
ge_anand6-Jul-05 20:26 
GeneralSetup Issue Pin
waffleman5-Jul-05 0:07
waffleman5-Jul-05 0:07 
GeneralRe: Setup Issue Pin
ge_anand5-Jul-05 7:57
ge_anand5-Jul-05 7:57 
GeneralRe: Setup Issue Pin
rwestgraham6-Jul-05 13:24
rwestgraham6-Jul-05 13:24 
QuestionCOM InterOp with Delegate(Event) support? Pin
Huisheng Chen4-Jul-05 22:51
Huisheng Chen4-Jul-05 22:51 
General[ Active Directory ] Retrieve Terminal Services User Profile Path Pin
Jaymz6664-Jul-05 5:21
Jaymz6664-Jul-05 5:21 
GeneralGood Book for .NET and C# Pin
ameysp4-Jul-05 1:12
ameysp4-Jul-05 1:12 
GeneralRe: Good Book for .NET and C# Pin
MoustafaS4-Jul-05 8:42
MoustafaS4-Jul-05 8:42 
GeneralRe: Good Book for .NET and C# Pin
Mike Dimmick4-Jul-05 11:22
Mike Dimmick4-Jul-05 11:22 
GeneralRe: Good Book for .NET and C# Pin
Christian Graus4-Jul-05 13:22
protectorChristian Graus4-Jul-05 13:22 
GeneralRe: Good Book for .NET and C# Pin
MKlucher4-Jul-05 15:18
MKlucher4-Jul-05 15:18 
GeneralRe: Good Book for .NET and C# Pin
ameysp4-Jul-05 18:55
ameysp4-Jul-05 18:55 
GeneralRe: Good Book for .NET and C# Pin
Kevin McFarlane6-Jul-05 9:50
Kevin McFarlane6-Jul-05 9:50 
GeneralRe: Good Book for .NET and C# Pin
dwatkins@dirq.net18-Jul-05 3:56
dwatkins@dirq.net18-Jul-05 3:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.