Garbage Collection

Garbage Collection
0.0 0


I noticed that my gameloop leaks a lot of memory unless I explicitly put in some collectgarbage(…) calls. Should we be looking at integrating this in the templates/hellolua or is it the intention that it will be bespoke per project?


I have noticed it. It seems the leak is caused by tolua++. I am not sure.


Just to clear things up, for me (at least) the getPosition()/setPosition() calls on my sprites generates a lot of 32byte objects. These are not leaked by lua. They’re just generated so fast/often per-frame the default Lua GC settings don’t ever get a chance to catch up!

For me, adding the lines :

collectgarbage( "setpause", 100) 
collectgarbage( "setstepmul", 5000)

Before the game-loop. Keeps the memory in-check with no apparent frame drop-offs, so no leaks :wink:


Nice solution!


ciaran jessup:

Where did you add these lines?


I am sorry, I haven’t seen:
Before the game-loop


no worries. You can actually place them anywhere (within the gameloop) … allowing you to adapt to your needs. Please also note some pull requests were submitted to reduce the initial footprint too :slight_smile: