Closed alfux closed 2 months ago
There is a good chance this is because of something MoltenVK is doing @aitor-lunarg could you help take a quick look at this or know anything around this
The PR above should address the issue. I've yet to test the set up locally myself (I will get to it later during the day), but I'm confident that's the issue.
Environment:
- OS: macOS Sonoma 14.5
- GPU and driver version: Apple M2
- SDK or header version if building from repo: 1.3.290.0
- Options enabled (synchronization, best practices, etc.): Nothing (I think?)
Describe the Issue
When I use debug utils messenger with vkCreateInstance and vkDestroyInstance, I get a memory leak at the end of the program.
Expected behavior
No memory leak.
Additional context
I'm following the Khronos Vulkan Tutorial (https://docs.vulkan.org/tutorial/latest) and I get a memory leak when I check the app with the command
leaks --atExit -- ./vulkan_leak_test
.This is a small test program I wrote to reproduce the issue. This is the makefile I use to compile. This is the output with the debug utils messenger created. And this is the output without the debug utils messenger.
Thanks for submitting such complete info, and a replicable sample! That helps enormously in tracking down issues!
@alfux can we close this issue now?
@spencer-lunarg Yes of course ! Thanks for the fix !
Environment:
Describe the Issue
When I use debug utils messenger with vkCreateInstance and vkDestroyInstance, I get a memory leak at the end of the program.
Expected behavior
No memory leak.
Additional context
I'm following the Khronos Vulkan Tutorial (https://docs.vulkan.org/tutorial/latest) and I get a memory leak when I check the app with the command
leaks --atExit -- ./vulkan_leak_test
.This is a small test program I wrote to reproduce the issue.
```c++ #includeThis is the makefile I use to compile.
```Makefile SRC := main.cpp OBJ := main.o VULKAND := /Users/alfux/VulkanSDK/1.3.290.0/macOS VULKANL := -L$(VULKAND)/lib -lvulkan -rpath $(VULKAND)/lib VULKANI := -I$(VULKAND)/include CFLAGS += -Wall -Wextra -g -std=c++2b CC := c++ NAME := vulkan_leak_test all : $(NAME) $(NAME) : $(OBJ) $(CC) $(CFLAGS) $(VULKANL) $^ -o $@ %.o : %.cpp $(CC) $(CFLAGS) $(VULKANI) -c $< -o $@ clean : rm -rf $(OBJ) fclean : clean rm -rf $(NAME) re : fclean all .PHONY : all clean fclean re ```This is the output with the debug utils messenger created.
``` leaks --atExit -- ./vulkan_leak_test vulkan_leak_test(82624) MallocStackLogging: could not tag MSL-related memory as no_footprint, so those pages will be included in process footprint - (null) vulkan_leak_test(82624) MallocStackLogging: recording malloc and VM allocation stacks using lite mode Start of the test program Info[1]: Searching for ICD drivers named ../../../lib/libMoltenVK.dylib Info[1]: Loading layer library /Users/alfux/VulkanSDK/1.3.290.0/macOS/share/vulkan/explicit_layer.d/../../../lib/libVkLayer_khronos_validation.dylib Info[1]: Unloading layer library /Users/alfux/VulkanSDK/1.3.290.0/macOS/share/vulkan/explicit_layer.d/../../../lib/libVkLayer_khronos_validation.dylib End of the test program Process 82624 is not debuggable. Due to security restrictions, leaks can only show or save contents of readonly memory of restricted processes. Process: vulkan_leak_test [82624] Path: /Users/USER/Desktop/*/vulkan_leak_test Load Address: 0x100590000 Identifier: vulkan_leak_test Version: 0 Code Type: ARM64 Platform: macOS Parent Process: leaks [82623] Date/Time: 2024-08-18 19:55:53.225 +0200 Launch Time: 2024-08-18 19:55:52.235 +0200 OS Version: macOS 14.5 (23F79) Report Version: 7 Analysis Tool: /usr/bin/leaks Physical footprint: 11.5M Physical footprint (peak): 11.5M Idle exit: untracked ---- leaks Report Version: 4.0, multi-line stacks Process 82624: 2394 nodes malloced for 385 KB Process 82624: 1 leak for 96 total leaked bytes. STACK OF 1 INSTANCE OF 'ROOT LEAK:And this is the output without the debug utils messenger.
```c++ create_info.pNext = nullptr; ``` Output: ``` leaks --atExit -- ./vulkan_leak_test vulkan_leak_test(82667) MallocStackLogging: could not tag MSL-related memory as no_footprint, so those pages will be included in process footprint - (null) vulkan_leak_test(82667) MallocStackLogging: recording malloc and VM allocation stacks using lite mode Start of the test program End of the test program Process 82667 is not debuggable. Due to security restrictions, leaks can only show or save contents of readonly memory of restricted processes. Process: vulkan_leak_test [82667] Path: /Users/USER/Desktop/*/vulkan_leak_test Load Address: 0x104ebc000 Identifier: vulkan_leak_test Version: 0 Code Type: ARM64 Platform: macOS Parent Process: leaks [82666] Date/Time: 2024-08-18 19:57:29.309 +0200 Launch Time: 2024-08-18 19:57:28.935 +0200 OS Version: macOS 14.5 (23F79) Report Version: 7 Analysis Tool: /usr/bin/leaks Physical footprint: 11.5M Physical footprint (peak): 11.5M Idle exit: untracked ---- leaks Report Version: 4.0, multi-line stacks Process 82667: 2393 nodes malloced for 385 KB Process 82667: 0 leaks for 0 total leaked bytes. ```I apologize if the issue is on my end, I'm just starting to learn Vulkan, but as I don't see any handle to this feature I don't know if I can or should free the memory myself as with the debug utils messenger we get with vkCreateDebugUtilsMessengerEXT and destroy with vkDestroyDebugUtilsMessengerEXT. The Khronos Vulkan tutorial seems to suggest vkDestroyInstance should clean up the debug utils messenger at the end of this section: https://docs.vulkan.org/tutorial/latest/03_Drawing_a_triangle/00_Setup/02_Validation_layers.html#_debugging_instance_creation_and_destruction