Severe memory leak upon rendering player

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
Ethan_Pixelate
Prole
Posts: 7
Joined: Fri Dec 06, 2019 11:26 pm

Severe memory leak upon rendering player

Post by Ethan_Pixelate »

OH NO! Its the EVIL Mario sprite OF DOOM!, long story short, rendering mario sprite on my raspberry pi causes mysterious freezing, then find out on windows that its a memory leak, a memory leak so severe that it jumped from around 70MB of ram usage to 4GB of ram, nearly choking all the free memory i have, reigning it's unholy wrath down on my poor innocent computer with the fury of a thousand gods. I dont know how to fix this and i have looked at similar cases with no luck :( . The .love is attached below (it is bundled with the memory leak so be careful and dont let it dissintegrate your ram)

Navigation around the project:

main.lua simply loads in the game, because its also possible to launch a crappy chunk editor by running it on the command line via "-editor"
game.lua the actual game file
Assets_Scripts/TilesetLoader.lua not the problem, but it is responsible for slicing tilesets (including mario sprite) into tiles
Assets_Scripts/AnimatedDrawables.lua still not the problem but also slices images up tileset-style, but for animation
Assets_Images/Mario.png the mario sprite being sliced

Mario.png gets sliced at game.lua:58
Mario gets rendered at game.lua:381
Attachments
AAAAAAAA.love
(20.41 MiB) Downloaded 180 times
User avatar
zorg
Party member
Posts: 3444
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Severe memory leak upon rendering player

Post by zorg »

Hi and welcome to the forums.

Okay, i had a look, but the project's huge already...

While i didn't see any too obvious issues regarding creating tons of löve objects each update (which still might be the case though), i did notice your LoadTileset function creating both ImageDatas *and* Images for each tile you iterate over;

That in and of itself is both very RAM and VRAM heavy;

Consider not caring about ImageDatas at all, and rather just load your whole tileset in as an Image, along with using one or more SpriteBatch objects so things won't waste that much space.
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.
User avatar
pgimeno
Party member
Posts: 3549
Joined: Sun Oct 18, 2015 2:58 pm

Re: Severe memory leak upon rendering player

Post by pgimeno »

In line 381 you're calling love.draw, which is the same event you're in. That should be love.graphics.draw.
Ethan_Pixelate
Prole
Posts: 7
Joined: Fri Dec 06, 2019 11:26 pm

Re: Severe memory leak upon rendering player

Post by Ethan_Pixelate »

zorg wrote: Sat Feb 29, 2020 2:00 pm Hi and welcome to the forums.

Okay, i had a look, but the project's huge already...

While i didn't see any too obvious issues regarding creating tons of löve objects each update (which still might be the case though), i did notice your LoadTileset function creating both ImageDatas *and* Images for each tile you iterate over;

That in and of itself is both very RAM and VRAM heavy;

Consider not caring about ImageDatas at all, and rather just load your whole tileset in as an Image, along with using one or more SpriteBatch objects so things won't waste that much space.
Ill consider trying something like that, i never even knew what sprite batches were until i read this post and looked it up. Thank you!
pgimeno wrote: Sat Feb 29, 2020 2:45 pm In line 381 you're calling love.draw, which is the same event you're in. That should be love.graphics.draw.
Well. That explains alot. Thank you!

:awesome:
Post Reply

Who is online

Users browsing this forum: Semrush [Bot] and 91 guests