I have discover that the C-runtime has in own heap ( and also all the Heap API under windows HeapWalk..). I'm a little bit in trouble in regard of my previous knowledge in the way it seems a Process have in fact several Heaps and not only one. Is it right ? And if it is the case, why there is the need of several Heaps?
A Windows process generally has at least 3 heaps:
It is not uncommon to have multiple CRT heaps, any DLL that was built with /MT has its own copy of the CRT and thus gets its own heap. The exact reason why it wasn't contemplated to only ever allocate from a single heap is murky to me.
The GetProcessHeaps() function is available to iterate all the heaps in the process.
UPDATE: the murky part got unmurked a bit. Starting with VS2012, the CRT now allocates from the default process heap, first bullet. Keep in mind that this doesn't retroactively changes the behavior on old DLLs that were not rebuilt.
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