KomputeProject / kompute

General purpose GPU compute framework built on Vulkan to support 1000s of cross vendor graphics cards (AMD, Qualcomm, NVIDIA & friends). Blazing fast, mobile-enabled, asynchronous and optimized for advanced GPU data processing usecases. Backed by the Linux Foundation.
http://kompute.cc/
Apache License 2.0
1.88k stars 145 forks source link

Memory leak in Algorithm destructor #365

Open Archie3d opened 4 months ago

Archie3d commented 4 months ago

Running on Windows with MSVC, I am getting memory leak reports because of Algorithm::destroy not not freeing push and specialization constants. The comment says that they are supposed to be freed by the command buffer destructor, but I am not sure this is the case. When freeing them explicitly here like in the commented code, I don't get memory leaks from using constants anymore.

axsaucedo commented 5 days ago

@Archie3d is this something you can provide an example to reproduce?

Archie3d commented 4 days ago

@axsaucedo Any example that uses push or specialization constants leaks memory. Freeing these explicitly in Algorithm::destroy() fixes this issue (see https://github.com/Archie3d/kompute/commit/5a564a148ef0771764ba228769715102458e203a)

The commented code says that "vk::CommandBuffer frees the data", but this is not the case. vkCmdPushConstants does not mention anything about retaining the data pointer, and actually I don't think Vulkan ever retains any data pointer passed to it (please see this comment).