Is custom RAM assignment possible?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
-
- Prole
- Posts: 7
- Joined: Thu Aug 27, 2015 12:58 am
Is custom RAM assignment possible?
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?
Re: Is custom RAM assignment possible?
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
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
-
- Prole
- Posts: 7
- Joined: Thu Aug 27, 2015 12:58 am
Re: Is custom RAM assignment possible?
I used Windows task manager. I hope I did things correctlyNixola wrote:How did you measure RAM usage?
- slime
- Solid Snayke
- Posts: 3162
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: Is custom RAM assignment possible?
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.
-
- Prole
- Posts: 7
- Joined: Thu Aug 27, 2015 12:58 am
Re: Is custom RAM assignment possible?
Well the algorithm is pretty simple. The issue might be that it's repeated 10000 times for each frame.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.
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
- kikito
- Inner party member
- Posts: 3153
- Joined: Sat Oct 03, 2009 5:22 pm
- Location: Madrid, Spain
- Contact:
Re: Is custom RAM assignment possible?
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.
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.
-
- Prole
- Posts: 7
- Joined: Thu Aug 27, 2015 12:58 am
Re: Is custom RAM assignment possible?
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.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.
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.
Who is online
Users browsing this forum: Bing [Bot] and 8 guests