I recently finished the base implementation of a DX12 rederer and I started to think in ways of improving the performance. I think that one problem that my implementation has, is memory fragmentation, as I mostly perform "single" allocations for my resources. During run-time some resources are deleted and recreated which I guess will cause even more memory frag. There are quite a few articles online about writing system memory managers but I've never encountered something like that for video memory and GPU resources.

Could anyone explain the basics of a system like this? Thanks!

EDIT: I had this link laying around: Memory Management in Direct3D 12 | Windows Dev Center. That gives some good general information about the topic.


1 Answer 1


Whenever there's too much churn of things being created and destroyed, regardless of the specifics of the situation, a common way to dealing with this is to make free object pools.

How these work is when you are done using something, instead of actually freeing or destroying it, you put it back into a list or array of "free objects".

When you need a new object of a specific type, you check the object pool to see if there's a free one lying around. If there isn't one there, you create a new one the "expensive" way and use it. When you are done with it, you put it in the free pool for use in the future.

A possible issue with free object pools is that you may have a spike in objects for some reason and then you are left with a ton of unused objects sitting in a free pool that will never be needed again. In situations like this, you can keep track of how long (in number of frames for instance) since an object was last used, and if they get over a certain unused age, free them from the object pool.

PS - make sure and profile your code to find what the ACTUAL performance bottlenecks are before attempting to solve problems. Optimizing without profiling before (to find the problem) and after (to verify you improved things, and knowing by how much) won't get you very far (:

  • 1
    $\begingroup$ That could be a nice approach, I think we don't have inconsistencies on that aspect, but as I said, there are quite a few allocs and deallocs. And yeah, I have to start doing some profiling but I really think that this could be a potential improvement :). Thanks! $\endgroup$
    – Nacho
    Commented Oct 5, 2017 at 8:40
  • 1
    $\begingroup$ You can make your pool allocate groups of objects, say 64 objects at a time when requesting an object, by linking the first object in that block to your 'used list' and the other 63 to your 'free list' to avoid hammering the memory allocator. $\endgroup$
    – PaulHK
    Commented Mar 4, 2018 at 6:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.