Does Vulkan prevent the local device memory fragmentation?

I hope it is not already asked, but as the question says, after a series of allocations and releases, the device memory may become fragmented and, despite having enough memory for a request, the runtime won’t provide a valid pointer because that memory isn’t contiguous. Does Vulkan prevent this in any form? or should we write our own managers to address such issue?

Thanks :slight_smile:

[QUOTE=SantiagoAlberto;42632]I hope it is not already asked, but as the question says, after a series of allocations and releases, the device memory may become fragmented and, despite having enough memory for a request, the runtime won’t provide a valid pointer because that memory isn’t contiguous. Does Vulkan prevent this in any form? or should we write our own managers to address such issue?

Thanks :)[/QUOTE]

You should not be allocating and releasing memory in Vulkan sufficiently frequently for that to matter. Most applications that need to use Vulkan should make a fixed number of allocations.

Yes, that’s the correct way. You should keep API allocations down to a minimum and allocate in big chunks per memory type instead (e.g. 256 MB) and do sub-allocations yourself and then just offset for rendering.

If you need a basic example (without manual sub allocations) of how to do this, there is an [https://github.com/SaschaWillems/Vulkan/blob/master/scenerendering/scenerendering.cpp]example of this in my repository](https://github.com/SaschaWillems/Vulkan/blob/master/scenerendering/scenerendering.cpp).

I will take a look at that example. Thanks for your answers!