That's nothing. It isn't a lot of memory until it reaches 500MB. And for me it doesn't crash until around 900MB. But as long as you keep the collector turned on usually it'll clean it up (With a lot of lag every few seconds while it cleans it) as long as it can keep ahead of the amount. You have to be creating a LOT of garbage per frame though. A LOT. 3D is a lot of garbage because it's usually thousands of temporary tables with multiple entries per frame that are only used for that one frame and need to be removed later, but most cases you won't reach this.Muris wrote:Sorry for asking this on someones elses topic, but this got me curious.
How much is a lot? I am assuming the value is in megabytes after dividing by 1024, and on my game it keeps hopping between 0.6 and 1.5 which doesnt sound that much. It keeps getting cleaned up on my game maybe roughly every 2 seconds from 1.5 to 0.6.
I tried stacking up one npc with a lot of items, and it uses not so optimized algorithm to count a value for a movement (strategy rpg), and the garbage collector consumption jumped from 1 to 30 during the calculation while the game froze for a second or two.
For the lag problem in your last paragraph, you could try looking into threads, or if not threads, coroutines which let you run a long loop in parts while allowing the rest of the game to run while you wait. Freezing in Löve is basically when a loop is running for too long without the proper love.graphics.present() functions being called. So using coroutines, or even calling some extra update, draw and present functions in that loop every few hundred loops will keep it going. But it does slow it down slightly as you're taking time away from the calculation of whatever you're trying to process to draw a single frame. But it works and the user wouldn't be the wiser.