Reputation: 147
I have this state of the memory:
In the picture above we can see that process memory "Value" is 292 Mb but "Managed heap" is only 14 Mb. Is my understanding correct: "Value" contains managed and unmanaged memory, while "Managed heap" only contains managed memory?
Upvotes: 0
Views: 463
Reputation: 12733
As the color coding, the circle and the legends suggest, Value refers to the Private Bytes. It's a subset of a process' virtual memory. It includes managed and unmanaged memory, that is private and not shared with other processes. Private memory includes e.g. heaps and stacks:
Private Bytes is the current size, in bytes, of memory that this process has allocated that cannot be shared with other processes.
What is private bytes, virtual bytes, working set?
Managed heap refers to the heaps of managed applications, i.e. .NET applications. It is a subset of the Private Bytes.
After the garbage collector is initialized by the CLR, it allocates a segment of memory to store and manage objects. This memory is called the managed heap, as opposed to a native heap in the operating system.
There is a managed heap for each managed process. All threads in the process allocate memory for objects on the same heap.
To reserve memory, the garbage collector calls the Windows VirtualAlloc function and reserves one segment of memory at a time for managed applications. The garbage collector also reserves segments, as needed, and releases segments back to the operating system (after clearing them of any objects) by calling the Windows VirtualFree function.
https://learn.microsoft.com/en-us/dotnet/standard/garbage-collection/fundamentals#the-managed-heap
Upvotes: 1
Reputation: 310977
Yes the "Value" is the entire memory consumed by the process. The managed heap contains all managed memory. Managed memory is a subset of the process's total memory. Behind the scenes the runtime allocates memory for various things it does such as JIT, stacks for threads. If your program allocates unmanaged memory (either in your code, or in library code), it won't appear in the managed heap either.
Upvotes: 1