What is an unmanaged heap?
I thought any object based memory that the CLR manages was the managed heap, so why do we talk about an unmanaged heap?
Imagine you call a Win32 function using P/Invoke, and that allocates some memory using malloc
. The garbage collector has no visibility of that memory - it's unmanaged.
That may or may not be the context in which you've heard the term, of course - if you could point us to some examples, we may be able to help you more.
As per John Skeet - the managed
heap is the one that .net will manage for you, that all standard objects are created on, that you normally don't need to bother too much about because it is managed.
unmanaged
means that you are personally allocating memory, and so you are personally responsible for deallocating it, managing it yourself, and keeping track of what is being used.
So yes, object memory ( in the sense of normal object creation and destruction, things that derive from object ) is managed. It is the other stuff you need to worry about - non objects and memory allocated for them.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With