Memory Management in Lua
Posted: Sun Apr 01, 2012 7:30 pm
Hi friends,
I've started working on a game with Love2d recently with no prior experience using Lua. I am writing this post hoping that you can help me to understand how Lua deals with memory leaks before I add too many leaks to my game. =)
I primarily develop on my PC which runs Windows 7. To monitor memory usage, I am looking in the "Windows Task Manager" under "Memory (Private Working Set)" My assumption is that the memory used by Love2D is the memory used by my program and that when garbage collection frees memory, the listed amount will decrease.
So I start the game and do nothing while waiting for the memory usage reach equillibrium. When this happens after about 20 seconds the game has a memory usage of 26,808 K. I then rapidly press the 'i' key 15 times. The 'i' key turns the music off or starts it again when pressed. After doing this, the memory usage is 45,940 K.
Is this a memory leak? If so, could you help me to understand what's causing it? Most of my code is in the gameHandler.lua program. I handle sound using TESound.lua. (I call TESound.cleanup() with each update, so that should clean up music which has been stopped, right?)
Thanks in advance for any help.
I've started working on a game with Love2d recently with no prior experience using Lua. I am writing this post hoping that you can help me to understand how Lua deals with memory leaks before I add too many leaks to my game. =)
I primarily develop on my PC which runs Windows 7. To monitor memory usage, I am looking in the "Windows Task Manager" under "Memory (Private Working Set)" My assumption is that the memory used by Love2D is the memory used by my program and that when garbage collection frees memory, the listed amount will decrease.
So I start the game and do nothing while waiting for the memory usage reach equillibrium. When this happens after about 20 seconds the game has a memory usage of 26,808 K. I then rapidly press the 'i' key 15 times. The 'i' key turns the music off or starts it again when pressed. After doing this, the memory usage is 45,940 K.
Is this a memory leak? If so, could you help me to understand what's causing it? Most of my code is in the gameHandler.lua program. I handle sound using TESound.lua. (I call TESound.cleanup() with each update, so that should clean up music which has been stopped, right?)
Thanks in advance for any help.