How do i profile memory usage in love2d?

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
titangate
Prole
Posts: 11
Joined: Tue Apr 26, 2011 4:24 am

How do i profile memory usage in love2d?

Post by titangate »

I have been using ProFi to profile the running time of functions, which has been helpful; but is there anyway to investigate the memory allocations/dellocations/usages?

thanks in advance :awesome:
User avatar
Roland_Yonaba
Inner party member
Posts: 1563
Joined: Tue Jun 21, 2011 6:08 pm
Location: Ouagadougou (Burkina Faso)
Contact:

Re: How do i profile memory usage in love2d?

Post by Roland_Yonaba »

Yes, there is.
Just use collectgarbage, passing it 'count' as argument.

Code: Select all

function love.draw()
   love.graphics.print('Memory actually used (in kB): ' .. collectgarbage('count'), 10,10)
end
User avatar
Petunien
Party member
Posts: 191
Joined: Fri Feb 03, 2012 8:02 pm
Location: South Tyrol (Italy)

Re: How do i profile memory usage in love2d?

Post by Petunien »

LÖVE does only use the memory of the Lua task?
It doesn't need more?
"Docendo discimus" - Lucius Annaeus Seneca
User avatar
Inny
Party member
Posts: 652
Joined: Fri Jan 30, 2009 3:41 am
Location: New York

Re: How do i profile memory usage in love2d?

Post by Inny »

collectgarbage('count') shows the amount of memory that Lua is responsible for (i.e. stored in the lua_state, and subject to garbage collection). If you're using threads, it won't show what the other threads are using, and it won't (shouldn't) show what Love is using internally. Though, anything love stores in the lua Registry, that stuff could be counted, depending on how it's stored.
Roland_Yonaba wrote:

Code: Select all

function love.draw()
   love.graphics.print('Memory actually used (in kB): ' .. collectgarbage('count'), 10,10)
end
And interesting note about displaying that number this way (string concat operator), is that it impacts memory usage, meaning that the rate of memory growth displayed will be faster than it would actually be without the display. So, don't freak out when your process is shooting through memory like it's going out of style. What should concern you more is how often a GC cycle happens, which you'll notice as a sudden drop in the amount of memory used. GC cycles have the biggest impact on performance.
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 7 guests