In Vulkan, when we create resources, we later destroy them. On the other hand, resources that represent different memory objects or pools are allocated and freed. Memory objects bound to images and buffers are also freed. We should free them when we no longer need them.
Freeing a memory object
How to do it...
- Take the logical device's handle and store it in a variable of type VkDevice named logical_device.
- Take the variable of type VkDeviceMemory named memory_object, in which the handle of the memory object is stored.
- Call vkFreeMemory( logical_device, memory_object, nullptr ). Use the handle of the logical device, the handle of the memory object, and a nullptr value.
- For safety reasons, assign the VK_NULL_HANDLE value to the memory_object variable.