HeapCreate vs GetProcessHeap

I’m new to using Heap Allocation in C++.

I’m tryin to understand the scenario that will force someone to create a private heap instead of using the Process Heap. Isn’t Process Heap generally enough for most of the cases?


If you have a flurry of transient heap activity, using a private heap for that can be faster than churning on the process heap. If you start a thread and give it a private heap, it can be thread-safe in those heap operation without needing to deal with locking for them. There are other reasons, but these two are relatively common ones.

It is an easy way of using a memory pool, which is useful especially on deallocation: Instead of tracking the lifetime of many small objects and deleting them one after another, create a seperate heap for them and destroy the entire heap when you’re done.

Leave a Comment