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.
Memory Management in Lua
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Memory Management in Lua
- Attachments
-
- ravenLOVE.love
- (2.83 MiB) Downloaded 166 times
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Memory Management in Lua
To be honest, I see no problem. Memory fluctuations happen, you only need to worry if it starts to explode.
Help us help you: attach a .love.
Re: Memory Management in Lua
Hi,
Thank you for your reply.
My concern is this isn't just a fluctuation in memory usage.
If I spam the 'i' key for 2-3 minutes, the memory usage climbs up to 1,001,808 K (a gig!). If I wait and do nothing, the memory stays where it is. If the sound files were correctly freed, shouldn't the memory Love2d is using fall back to less than 30 M again?
Thank you for your reply.
My concern is this isn't just a fluctuation in memory usage.
If I spam the 'i' key for 2-3 minutes, the memory usage climbs up to 1,001,808 K (a gig!). If I wait and do nothing, the memory stays where it is. If the sound files were correctly freed, shouldn't the memory Love2d is using fall back to less than 30 M again?
Re: Memory Management in Lua
yeah forced collections aren't getting rid of anything significant
i noticed tesound creates a new sound object for each play, so it's possible dead sounds are still getting referenced somewhere, which would keep the gc from freeing them
could also be a memory leak in love itself but i would think something like that would have been noticed long ago
EDIT: nope the sounds are getting collected
i noticed tesound creates a new sound object for each play, so it's possible dead sounds are still getting referenced somewhere, which would keep the gc from freeing them
could also be a memory leak in love itself but i would think something like that would have been noticed long ago
EDIT: nope the sounds are getting collected
Re: Memory Management in Lua
That is in fact a memory leak. It's fixed for the next version though.
You can't do much about it in 0.7.2 sadly.
You can't do much about it in 0.7.2 sadly.
Right.Xgoff wrote:noticed long ago
Shallow indentations.
Re: Memory Management in Lua
well that explains itBoolsheet wrote:That is in fact a memory leak. It's fixed for the next version though.
You can't do much about it in 0.7.2 sadly.
Right.Xgoff wrote:noticed long ago
Who is online
Users browsing this forum: Ahrefs [Bot], Semrush [Bot], slime and 4 guests