gdnim
gdnim copied to clipboard
Hot reload memory leak
There's a small memory leak that occurs on hot reload. When reloading bullet.nim, memory increases by about 0.2MB when looking at the TaskManager on Windows. I don't know if this is happening inside Godot(GDNative initializing) or gdnim (Watcher). There doesn't seem to be any memory leak without hot reloading.
Looking at module/gdnative/nativescript/godot_nativescript.cpp, when something is registered it gets inserted into a Map. The insert method checks if the key already exists, and if so replaces the value. So reregistering on hot reload should have no leakage on the Godot side unless a class reloads with fewer properties, methods or signals.
This suggests there's a leak in gdnim. Probably with Watcher which might be related to #29 and general crashing in ARC/ORC.
The fix for ORC stability on reload didn't fix the memory leak. The size of the leak is dependent on how many nodes are reloaded.
The leak doesn't look like it's coming from Watcher based on what dumpInfo is showing. I can't rule out it's on gdnim's side.
At the minimum, the reload causes a 0.2MB leak, if I just change a float value and reload without instantiating anything new. In general usage this doesn't seem like a big deal, but it's something to be aware of.