Memory leak when destroying textures

Hello,

I’m trying to destroy a texture but some memory is leaking somewhere along the way. In order to delete my texture I call vkDestroyImageView, vkDestroySampler, vkDestroyImage and vkFreeMemory. I also remove the image descriptor in the descriptor set by overwriting it with the placeholder texture descriptor. But the vram and ram will continue to increase while the application runs. I’m a little bit lost as I feel like I’m not missing any resources to clean up. Any ideas on what I’m missing?

Here’s the code I have for my textures : https://gist.github.com/kretash/854db609d7c4cc5749cb

The last few functions are the ones that destroy the resources.

I also have a video of the application running with my vulkan renderer and with my d3d12 renderer if that helps in any way.
https://www.youtube.com/watch?v=zHSPRV2z3z0

Thanks!

Try infinite loop of texture creation\destruction. It could be that Vulkan driver simply behaves differently in from DX12 when in comes to memory management. If RAM consuption will stop rising at some point, it’s fine. Are you sure you are not leaking void* data in create_texture, btw? And don’t validation layers report anything?

It’s already running in an infinite loop and it does not stop. Both the vram and ram continue to increase until it crashes.

Void* data is being deleted afterwards and the validation layer is not reporting anything either. I have also run the application with vld and it does not report any leaks a part from minor controlled ones.

Here’s the code I have for my textures : https://gist.github.com/kretash/854db609d7c4cc5749cb

Please don’t make an allocation for a single texture. That’s really not how you’re supposed to use Vulkan. Vulkan implementations are allowed to have a limit on the number of independent memory allocations.

Your texture class’s design is just wrong for the API.

I changed that and It works fine now. I do 2 allocations at the beginning, one for VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT and another one for VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT.

[QUOTE=Alfonse Reinheart;39912]Please don’t make an allocation for a single texture. That’s really not how you’re supposed to use Vulkan. Vulkan implementations are allowed to have a limit on the number of independent memory allocations.

Your texture class’s design is just wrong for the API.[/QUOTE]

So, if I understand well, in Vulkan, a good way should be to manage ourselves whole the memory? Like make a big allocation and manage it ourselves, I mean without any vulkan call?