Closed robert-nix closed 6 years ago
Thanks @Mischanix ! I think we should split this into two parts, the first part is easy (adding explicit Free in NkPlatformRender). The second part is harder, because it involves cgo_helpers.go
which are automatically generated and should not be modified by hand. So I need to change c-for-go behaviour to respect that.
If you'd provide a small test program so I could see the leak, that would help a lot!
I've hacked in a little heap size routine for debugging on Windows: https://github.com/Mischanix/nuklear/commit/35b983c73a941c661d5f335f242f8437fe77830f.
I'm compiling this with mingw-w64 GCC from MSYS2. Using mallinfo may be a suitable alternative under linux.
So, in github.com/Mischanix/nuklear/cmd/nk-example
on Windows there is now a label showing that the heap is growing steadily from frame to frame.
I have put the manual fixes in a separate branch: https://github.com/golang-ui/nuklear/compare/master...Mischanix:manually-fix-memory-leaks?expand=1
@Mischanix your help is invaluable, thank you so much! I will use this example to figure out how to improve c-for-go to produce leak-free code for this.
Structures inside ConvertConfig are allocated but not freed by PassRef. Here's a diff of what I needed to modify in the generated code to stop the memory leak: