Page 1 of 1

image sequence - memory performance

Posted: Tue Feb 28, 2017 2:01 pm
by richy88
Hi, I'm trying to get an image sequence running.
The performance is very good until the DDR is completly full. After that the GC seems to start working and making some space for new images on RAM. Is there any manual way to free RAM?

Following a code snipped how I'm doing it right now: (maybe something realy simple I'm diong wrong?)

Code: Select all

img = "synctest_QFHD-DDS/"
start = 0001
ende = 3000
frame = start

function love.load()
	image = love.graphics.newImage(img .. string.format("%04d", frame) .. ".dds")
end

function love.draw()
	love.graphics.draw(image, 0, 0, 0, 0.5, 0.5)
end

function love.update(dt)
	image = love.graphics.newImage(img .. string.format("%04d", frame) .. ".dds")
	frame = frame % ende + 1
end

Re: image sequence - memory performance

Posted: Tue Feb 28, 2017 5:28 pm
by raidho36
You're loading an image from file every frame, and every frame you discard one i.e. leave in the garbage memory limbo until GC can pick it up. Is it not an option to keep all of them in the memory simultaneously?

Re: image sequence - memory performance

Posted: Wed Mar 01, 2017 7:14 am
by richy88
No, not an option really. The whole sequence is more than 10GB.

Re: image sequence - memory performance

Posted: Wed Mar 01, 2017 7:53 am
by raidho36
That's an awful lot of images. Consider compiling them into a video, LÖVE can play some formats.

Re: image sequence - memory performance

Posted: Wed Mar 01, 2017 8:11 am
by richy88
Sorry, not an option also. But I've found a solution. :)
Just added the following in the last line of love.update() function.

Code: Select all

collectgarbage()

Re: image sequence - memory performance

Posted: Wed Mar 01, 2017 10:28 am
by zorg
You know, from the snippet you posted, you could simplify a few things... though it won't have too much of an impact, probably:

Code: Select all

img = "synctest_QFHD-DDS/"
start = 0001
ende = 3000
frame = start

function love.load()
	-- Don't need to assign to image here, because...
end

function love.update(dt)
	collectgarbage()
	-- ...if you are using the default love.run, then love.update will be called first, then love.draw second, each "cycle"...
	image = love.graphics.newImage(string.format("%s%04d.dds", img, frame)) -- more compact
	frame = frame % ende + 1 -- i'd parenthesize these if i were you, operator precedence may be different than you'd expect.
end

function love.draw()
	-- ...meaning that this should never error with image being nil.
	love.graphics.draw(image, 0, 0, 0, 0.5, 0.5)
end