Tracking Memory Usage?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
OmarShehata
Party member
Posts: 259
Joined: Tue May 29, 2012 6:46 pm
Location: Egypt
Contact:

Tracking Memory Usage?

Post by OmarShehata »

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!
User avatar
slime
Solid Snayke
Posts: 3144
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Tracking Memory Usage?

Post by slime »

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.)
OmarShehata wrote:While we're on the same topic, any suggestions for helpful tools and profilers would be appreciated!
Which OS? :)
User avatar
OmarShehata
Party member
Posts: 259
Joined: Tue May 29, 2012 6:46 pm
Location: Egypt
Contact:

Re: Tracking Memory Usage?

Post by OmarShehata »

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.)
OmarShehata wrote:While we're on the same topic, any suggestions for helpful tools and profilers would be appreciated!
Which OS? :)
Ah okay! That makes sense!

And I'm on Windows. Thanks for the speedy reply slime!
User avatar
verilog
Citizen
Posts: 97
Joined: Thu Nov 03, 2011 3:15 am
Contact:

Re: Tracking Memory Usage?

Post by verilog »

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?
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests