image sequence - memory performance

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
richy88
Prole
Posts: 3
Joined: Tue Feb 28, 2017 1:55 pm

image sequence - memory performance

Post 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
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: image sequence - memory performance

Post 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?
richy88
Prole
Posts: 3
Joined: Tue Feb 28, 2017 1:55 pm

Re: image sequence - memory performance

Post by richy88 »

No, not an option really. The whole sequence is more than 10GB.
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: image sequence - memory performance

Post by raidho36 »

That's an awful lot of images. Consider compiling them into a video, LÖVE can play some formats.
richy88
Prole
Posts: 3
Joined: Tue Feb 28, 2017 1:55 pm

Re: image sequence - memory performance

Post 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()
User avatar
zorg
Party member
Posts: 3465
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: image sequence - memory performance

Post 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
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot] and 8 guests