Memory leak..... Help....

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
User avatar
Amatereasu
Prole
Posts: 9
Joined: Wed May 10, 2023 6:30 am

Memory leak..... Help....

Post by Amatereasu »

I have a memory leak in my game.. :'3
I'm not techincally versed in this stuff, how do I fix this?
I think its caused by mismanaged sprite data
https://cdn.discordapp.com/attachments/ ... -02-48.mp4
Will provide any code or anything else
User avatar
BrotSagtMist
Party member
Posts: 659
Joined: Fri Aug 06, 2021 10:30 pm

Re: Memory leak..... Help....

Post by BrotSagtMist »

Please dont post videos of such questions.

First glance, i dont see what you mean, thats how Lua operates normally.
But if you want to have your code sanity checked, you need to paste code.
obey
User avatar
deströyer
Prole
Posts: 32
Joined: Thu Jun 27, 2013 7:59 pm
Contact:

Re: Memory leak..... Help....

Post by deströyer »

some maybe obvious questions, but:
- are you remembering to remove entries from your notes table when they move offscreen?
- are you creating duplicates of the sprite (eg. every frame as opposed to just when you initialize)?
without any code, we can't really do anything except guess at what the causes might be.
User avatar
Amatereasu
Prole
Posts: 9
Joined: Wed May 10, 2023 6:30 am

Re: Memory leak..... Help....

Post by Amatereasu »

BrotSagtMist wrote: Sat May 13, 2023 8:32 am Please dont post videos of such questions.

First glance, i dont see what you mean, thats how Lua operates normally.
But if you want to have your code sanity checked, you need to paste code.
the memory usage rises and rises until it just crashes my PC lol
deströyer wrote: Sat May 13, 2023 3:27 pm some maybe obvious questions, but:
- are you remembering to remove entries from your notes table when they move offscreen?
- are you creating duplicates of the sprite (eg. every frame as opposed to just when you initialize)?
without any code, we can't really do anything except guess at what the causes might be.
in the clip im spawning the hearts, and when they go off screen theyre supposed to despawn:
in love.load:

Code: Select all

function noteSpawn(x, y, s)
    local note = {x = x, y = y, s = s}
    table.insert(notes, note)
end
in love.update(dt)

Code: Select all

for i, note in ipairs(notes) do
    note.x = note.x - (note.s * 100) * dt
    if note.x < 0 then
        table.remove(notes, i)
    end
end
in love.draw:

Code: Select all

for i, note in ipairs(notes) do
    love.graphics.draw(noteSpritesheet, note.x, note.y, nil, 4, 4, 12, 12)
end
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 11 guests