In my Windows' C++ program, I allocate several small objects on heap (thousands) by calling new CMyClass()
The performance seems to get affected due to this.
Is there a way to preallocate some minimum memory in heap for the program's use so that the OS starts allocating from this preallocated space when ever I call new CMyClass() to improve the performance?
Thanks.
You seem to be looking for a memory pool - http://www.codeproject.com/Articles/27487/Why-to-use-memory-pool-and-how-to-implement-it
Note that you can pre-allocate some memory and then use placement new to prevent multiple allocations.
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