Memory leak and GLFW crash, what am I doing wrong?

Hi, this is one of my first projects using Vulkan and I’m having a hard time fixing a possible memory leak and a weird crash on GLFW.

Memory leak

Below is the report I got from Clang’s LeakSanitizer. The first leak is one that I’ve caused on purpose by allocating 1 byte on each render call. The other ones I’m not really sure where they come from or how to fix them, but seems to be something related to libxcb.

=================================================================
==29287==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 925 byte(s) in 925 object(s) allocated from:
    #0 0x4c87b3 in __interceptor_malloc (/home/victor/CLionProjects/vulkanrendererc/cmake-build-debug-clang7-asan/vulkanrendererc+0x4c87b3)
    #1 0x500c35 in VulkanRenderer::drawFrame() /home/victor/CLionProjects/vulkanrendererc/src/VulkanRenderer.cpp:251:5
    #2 0x500be8 in VulkanRenderer::loop() /home/victor/CLionProjects/vulkanrendererc/src/VulkanRenderer.cpp:53:9
    #3 0x4fabce in main /home/victor/CLionProjects/vulkanrendererc/src/main.cpp:45:14
    #4 0x7f9e80f5409a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)

Direct leak of 88 byte(s) in 1 object(s) allocated from:
    #0 0x4c89aa in calloc (/home/victor/CLionProjects/vulkanrendererc/cmake-build-debug-clang7-asan/vulkanrendererc+0x4c89aa)
    #1 0x7f9e809ae2ce in xcb_register_for_special_xge (/lib/x86_64-linux-gnu/libxcb.so.1+0xe2ce)

Direct leak of 64 byte(s) in 2 object(s) allocated from:
    #0 0x4c89aa in calloc (/home/victor/CLionProjects/vulkanrendererc/cmake-build-debug-clang7-asan/vulkanrendererc+0x4c89aa)
    #1 0x7f9e7831d7d1  (<unknown module>)

SUMMARY: AddressSanitizer: 1077 byte(s) leaked in 928 allocation(s).

GLFW crash

The GLFW crash happens randomly but very often when I close the window without resizing so if somebody could shed me some light on what am I doing wrong, I’d appreciate it.

Also when I simply close the window without attaching the debugger I get corrupted double-linked list on stderr.

There’s nothing special about it but if needed, here’s my code: vulkanrendererc (15 KB)

I think corrupted double-linked list is when you accidentally overwrite your heap memory manager’s stuff. Basically an OOBA. Anyway, search internet, there seems to be lot of results.

Per the above preassumption it is reasonable free\delete malfunctions because of the corruption, causing a leak.

A crash can be anything. At least give a line.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.