Closed LordMonoxide closed 4 months ago
I was able to temporarily work around this issue by caching the result of memAddressSafe((NkPluginFilterI)Nuklear::nnk_filter_decimal)
and making my own nk_edit_string
that accepts a long for the filter param
AFAIK this is a side-effect of the API design here, see https://github.com/LWJGL/lwjgl3-wiki/wiki/1.4.-Bindings-FAQ#how-can-callbacks-from-native-code-be-configured. This wiki page also includes patterns for removing the leak.
I see, thanks for the information. I feel that using method references like this should be prevented by the API, but don't have any suggestions for that.
Version
3.3.3
Platform
Windows x64
JDK
Coretto 17/21, Oracle 15/16/17, I assume all
Module
Nuklear
Bug description
Calling
nk_edit_string
leaks memory due tomemAddressSafe
allocating a callback. Java process memory will grow indefinitely (system memory, not jvm heap). I ran it withConfiguration.DEBUG_MEMORY_ALLOCATOR.set(true)
and after leaving it running for a few minutes, when I shut it down the console is flooded with "bytes leaked" warnings.Example code:
Setting the last param (
filter
) to null prevents the callback instance from being allocated and no memory is leaked.Stacktrace or crash log output