This heap is highly fragmented. Allocating a memory block that contains 5 blocks (i.e., 5 consecutive minus signs) is impossible although the heap has a total of 12 free blocks. Ideally, the heap should look like this:
To avoid heap fragmentation use dynamic memory allocating sparingly. In many cases, you can replace new and new with static or automatic storage, or use STL containers. Secondly, try to allocate and deallocate large chunks in every new and delete expression instead of allocating small chunks frequently. Using placement new to preallocate a large buffer and then slice that buffer into smaller units will reduce the risk of heap fragmentation.
Take advantage of special member promotions, everyday discounts, quick access to saved content, and more! Join Today.