Hello everyone,
I am working on a game, however, I recently discovered that I may have a memory leak. After looking through the Developer Console, I noticed that the LuaHeap keeps increasing by 1 or 2 MB every second.
What is LuaHeap and what causes Memory leaks in the LuaHeap?
I removed all the unused variables from my code, however, it barely made a change.
If someone could help me with this situation, it would be greatly appreciated!
Thanks!
Edit: After analyzing the LuaHeap in the Developer Console, I receive this pattern. Could this mean anything?
I’m not pretty sure but what I found is that it’s some kind of garbage-collector, I found this topic that talks about Heap in Lua. I don’t think that is pretty useful since almost nobody would look into Memory and find LuaHeap.
Here is a screenshot of the Lua Heap along with a screenshot of the Microprofiler. Can someone please tell me how to diagnose which script is causing the increase of the LuaHeap.
I haven’t seen any of your code, but are you cleaning up connections, instance references and so on properly? Such as if you store data in a table with an instance (like a player) as key, the table isn’t automatically garbage collected when the player leaves because the reference still exists.
Connections should also be properly disconnected when you destroy the instance, when a player leaves and so forth.
I have just revised all of my code (a very complex process) and manage to diagnose the issue and fix it! Turns out I had a few connections which I should have disconnected in a few modules. Thanks!