Is custom RAM assignment possible?

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
Telecorpse
Prole
Posts: 7
Joined: Thu Aug 27, 2015 12:58 am

Is custom RAM assignment possible?

Post by Telecorpse »

I've been recently making a program that creates pretty complicated visuals. Unfortunately the application runs at about 1 FPS and my processor is barely used. I found out that the program's RAM consumption caps at 38MB. Is there a way to assign more RAM to the game?
User avatar
Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: Is custom RAM assignment possible?

Post by Nixola »

How did you measure RAM usage?
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
Telecorpse
Prole
Posts: 7
Joined: Thu Aug 27, 2015 12:58 am

Re: Is custom RAM assignment possible?

Post by Telecorpse »

Nixola wrote:How did you measure RAM usage?
I used Windows task manager. I hope I did things correctly :)
User avatar
slime
Solid Snayke
Posts: 3162
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Is custom RAM assignment possible?

Post by slime »

It sounds like the low framerate is probably due to unoptimized usage of love.graphics functions rather than a RAM-related thing. If you post a .love or further describe what you're doing (graphics-wise) and what you want it to look like, we can hopefully provide some good performance-improving advice.
Telecorpse
Prole
Posts: 7
Joined: Thu Aug 27, 2015 12:58 am

Re: Is custom RAM assignment possible?

Post by Telecorpse »

slime wrote:It sounds like the low framerate is probably due to unoptimized usage of love.graphics functions rather than a RAM-related thing. If you post a .love or further describe what you're doing (graphics-wise) and what you want it to look like, we can hopefully provide some good performance-improving advice.
Well the algorithm is pretty simple. The issue might be that it's repeated 10000 times for each frame.
Anyway I ran the program on two different machines and the framerate was pretty much the same

Here's the code

Code: Select all

function love.load()
	line = 10000 -- number of lines
	rd = math.pi / (line / 2)
	n = 1
	speed = 0.5
	alpha = 5
	dir = 0
end
function love.update(dt)
	if love.keyboard.isDown("up") then
		dir = 1
	elseif love.keyboard.isDown("down") then
		dir = -1
	elseif love.keyboard.isDown(" ") then
		dir = 0
	end
	if speed >= 0 then
		if love.keyboard.isDown("w") then
			speed = speed + dt
		elseif love.keyboard.isDown("s") then
			speed = speed - dt
		end
	else
		speed = 0
	end
	n = n + speed * dir * dt
end
function love.draw()
	love.graphics.setColor(255, 255, 255, 255)
	love.graphics.print(n)
	love.graphics.print(speed, 0, 15)
	for k = 1, line do
		if k % 3 == 1 then
			love.graphics.setColor(255, 0, 0, alpha)
		elseif k % 3 == 2 then 
			love.graphics.setColor(0, 255, 0, alpha)
		elseif k % 3 == 0 then
			love.graphics.setColor(0, 0, 255, alpha)
		end
		love.graphics.line(400 + 300 * math.sin(k * rd), 300 + 300 * math.cos(k * rd), 400 + 300 * math.sin(k * n * rd), 300 + 300 * math.cos(k * n * rd))
	end
end
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: Is custom RAM assignment possible?

Post by kikito »

Yes, those 10k draw calls certainly will slow things down.

It seems that you are changing the lines only when a key is pressed (the code handling this is a bit messy and I might be mistaken). If that's the case, I'd suggest drawing into a canvas - only updating it when a key is pressed (when speed is > 0). That way you would "pay the price" of drawing all those lines only when the speed is changed, not on every frame.
When I write def I mean function.
Telecorpse
Prole
Posts: 7
Joined: Thu Aug 27, 2015 12:58 am

Re: Is custom RAM assignment possible?

Post by Telecorpse »

kikito wrote:Yes, those 10k draw calls certainly will slow things down.

It seems that you are changing the lines only when a key is pressed (the code handling this is a bit messy and I might be mistaken). If that's the case, I'd suggest drawing into a canvas - only updating it when a key is pressed (when speed is > 0). That way you would "pay the price" of drawing all those lines only when the speed is changed, not on every frame.
Nah, the "up" and "down" keys control whether n is increased or decreased by the speed. I should really move that to love.keypressed function.
The value of n when dir != 0 is changing every frame, so the lines should also be updated at every frame.
Anyway the visuals look awesome even at 500 lines. I just tried to smooth the patterns out.
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 5 guests