kompute icon indicating copy to clipboard operation
kompute copied to clipboard

Memory leak in Algorithm destructor

Open Archie3d opened this issue 1 year ago • 2 comments

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.

Archie3d avatar Mar 14 '24 16:03 Archie3d

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

axsaucedo avatar Jul 25 '24 18:07 axsaucedo

@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).

Archie3d avatar Jul 25 '24 19:07 Archie3d