Page 1 of 1

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

Posted: Sat May 13, 2023 8:09 am
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

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

Posted: Sat May 13, 2023 8:32 am
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.

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

Posted: Sat May 13, 2023 3:27 pm
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.

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

Posted: Sat May 13, 2023 4:19 pm
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