Mesh Garbage Collection Issue
Posted: Thu Jan 04, 2018 6:13 am
Hey, y'all, first post here. I'm making a 3D game, so I rely on LÖVE's built in meshes, and I use them heavily, creating many of them at a time when needed and freeing them when needed no longer, because it'd otherwise use a lot of memory to keep them around. However, I seem to have memory issues regardless, and I feel like it's an issue with LÖVE itself, not my own code.
Here's the issue I'm facing: I create a large amount of mesh objects all at once, and then later on I'll nil a bunch of them at the same time and have Lua garbage collect them, and Lua's own collectgarbage("count") value decreases back to the value from before they were created, but the memory count in Task Manager only decreases slightly and never comes close to the original memory value. Is LÖVE failing to free the mesh objects from memory after they're garbage collected?
This is a big issue, because the game loads and unloads tons of mesh data, and after a while memory usage will hang around the 500-600 MB range, when it's typically only between 250-350 MB. I've debugged everything madly and can't seem to find a leak in my own code, so I made a small .love file where I managed to reproduce the issue.
I've attached the .love file to this post. To reproduce the issue, launch the program and Task Manager. The automatic garbage collector will be stopped. Hold F to create meshes without storing them anywhere until you've used up a ludicrous amount of memory, then press G to run a full garbage collection cycle. Lua will report the meshes as having been garbage collected, but Task Manager will not. Here's a visual of what I mean.
I'm running 0.10.2, and I've tested this on Windows with Task Manager, macOS with its own Activity Monitor application, and I even compiled the latest version of 0.11.0 from the repo and tested that, and I get the same results each time.
Is there some way to fix this?
Here's the issue I'm facing: I create a large amount of mesh objects all at once, and then later on I'll nil a bunch of them at the same time and have Lua garbage collect them, and Lua's own collectgarbage("count") value decreases back to the value from before they were created, but the memory count in Task Manager only decreases slightly and never comes close to the original memory value. Is LÖVE failing to free the mesh objects from memory after they're garbage collected?
This is a big issue, because the game loads and unloads tons of mesh data, and after a while memory usage will hang around the 500-600 MB range, when it's typically only between 250-350 MB. I've debugged everything madly and can't seem to find a leak in my own code, so I made a small .love file where I managed to reproduce the issue.
I've attached the .love file to this post. To reproduce the issue, launch the program and Task Manager. The automatic garbage collector will be stopped. Hold F to create meshes without storing them anywhere until you've used up a ludicrous amount of memory, then press G to run a full garbage collection cycle. Lua will report the meshes as having been garbage collected, but Task Manager will not. Here's a visual of what I mean.
I'm running 0.10.2, and I've tested this on Windows with Task Manager, macOS with its own Activity Monitor application, and I even compiled the latest version of 0.11.0 from the repo and tested that, and I get the same results each time.
Is there some way to fix this?