I had a memory leak in my game trying to load and unload images, and as I was fixing it, I thought it would be convenient to have the RAM consumption displayed in the game instead of having to look at the task manager.
I'm using collectgarbage("count") to track this, and it seems like the values reported by that and the task manager are wildly different. Assuming this output the ram used in kilobytes, I get up to 30 mb reported while the task manager says I've gone up to 1 gb.
Is collectgarbage("count") supposed to be an accurate way to track memory consumption? I know the leak is coming from references to images not being garbage collected, if that makes any difference.
While we're on the same topic, any suggestions for helpful tools and profilers would be appreciated!
Tracking Memory Usage?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- OmarShehata
- Party member
- Posts: 259
- Joined: Tue May 29, 2012 6:46 pm
- Location: Egypt
- Contact:
- slime
- Solid Snayke
- Posts: 3144
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: Tracking Memory Usage?
collectgarbage("count") will only track memory used by Lua, so it won't report the true size of LÖVE objects (since their memory is handled in the C++ side of LÖVE, for the most part.)
Which OS?OmarShehata wrote:While we're on the same topic, any suggestions for helpful tools and profilers would be appreciated!
- OmarShehata
- Party member
- Posts: 259
- Joined: Tue May 29, 2012 6:46 pm
- Location: Egypt
- Contact:
Re: Tracking Memory Usage?
Ah okay! That makes sense!slime wrote:collectgarbage("count") will only track memory used by Lua, so it won't report the true size of LÖVE objects (since their memory is handled in the C++ side of LÖVE, for the most part.)
Which OS?OmarShehata wrote:While we're on the same topic, any suggestions for helpful tools and profilers would be appreciated!
And I'm on Windows. Thanks for the speedy reply slime!
Re: Tracking Memory Usage?
Hi Omar, have you tried ProFi.lua as a profiling tool? That's what I'm currently using; Its interface is very basic, but should give you an idea of how your code is performing. Also, how did you discover the memory leak? Just by looking at the task manager? or any other in-game unusual behaviour?
Who is online
Users browsing this forum: Google [Bot] and 4 guests