Funkin
Funkin copied to clipboard
Fixed major memory usage issues
When assets are loaded into the game, they are never unloaded. This can cause many issues related to significant RAM usage. Most issues that complain about characters loading as black boxes are from running out of memory. This also causes slowdowns as the system runs out of RAM. I found these issues myself playing the game normally for the first time, and it seems like a very critical issue. I'll note that in the cases where assets are loading as black boxes, that's more from devices with 4 gigs of RAM or so, so it may not be able to load the assets initially at all when loading the game. Because of that, this request may not fix all instances of black boxes from happening, but I think it'll help/prevent it in a lot of cases because it'll keep memory as low as it can.
Anyways, my solution overwrites the Haxe add
command, and adds the object you're adding to an array of of tracked assets, then it loads the asset in as it would normally. Then in key areas (like when a song gets finished, or when going from a menu to a song), it'll unload the assets using the Haxe remove
command. There are a few areas I manually unloaded some assets, like the GameOverSubstate, just because there's only one or two assets ever loaded.
TL;DR: This cleanly and dynamically keeps track of and removes unneeded assets to stop clogging up memory. This fixes some pretty significant issues.
(Memory usage outright) #856 #280 #58
(Black boxes/Characters just not loading) #1021 #992 (There are more I just don't want to search through it all lol)
Let me know if you have any questions or comments! Pretty happy with how clean the implementation is.
raspi 4: My time has come
ninja, if u see this, merge or ur a poopy fart
insult of the year
i know im a baddie
raspi 4: My time has come
I have a Raspberry Pi 4 (4GB RAM) and it would be cool to see the FPS on that thing, and play the game without squares
ninja, if u see this, merge or ur a poopy fart
hdboye when ninjamuffin doesn't merge this : https://youtu.be/EEuFbmmuqK4
Sad, maybe it's works in desktop, but in mobile created crash.
Sad, maybe it's works in desktop, but in mobile created crash.
How did you go about compiling for mobile?
what about the songs that get loaded in? from what i'm seeing they dont seem to be unloading
actually since the game uses openfl libraries you could try to use the unloadLibrary() function of openfl.utils.Assets. i could make a proof of concept out of it
Frankly, if you were to make a PoC then you may as well make an alternative PR with similar goals.
Frankly, if you were to make a PoC then you may as well make an alternative PR with similar goals.
i tried it! but unfourtanetly the results were dissapointing
basically what the function actually does is unload the library and it's paths, not unload the library from memory, which i find dissapointing
Cool ass PR FR. Adding this shit in 👍