No GC until 1 minute and then GC spike


I’m just not seeing any GC at all for the first minute or so of running my game, and then suddenly there’s a ton of GC resulting in a big spike.

I would expect to see regular smaller GC hits, rather than the one large lump.

The source of my GC is known to be allOverlappingSprites()



  • constant GC, as expected (shows as dark grey)

1.1.0 with frame rate fix, default GC settings

  • default GC settings
  • custom 5ms GC setting
  • custom 5ms plus setGCScaling(x,y) settings

all give the same result.

  • no GC at all… (just light grey)

Shortly after the above screen screen grab a sudden GC spike led to this:

  • …then, sudden large GC spike
  • approx 10x previous level on the chart

Original post

Using default GC settings I am seeing a big GC hit and resultant frame rate stutter.

  • This happens after 1 minute of my game running
  • and every 1 minute after that
  • I can reproduce it on demand
  • changes to setMinimumGCTime() and setGCScaling() make no difference?
  • also happens with my recent demo which was built with 1.0.8 SDK


  • all timers are removed from my game
  • GC hit is usually in allOverlappingSprites(), one of my most called functions, declared as local+const


  • is this a problem with the way my game works?
  • or is it something outside of my control?


Screen recording

ps: I am using a 1.1.1 test version

Upgrading this to a Bug Report. :thinking:

Interestingly, if I do manual collectgarbage() calls in my code then I can see GC() calls every frame.

But why are they not happening regularly with default settings?

This is fixed in 1.1.1.

When a game requests immediate frame updates with setRefreshRate(0), we weren’t giving time for inter-frame garbage collection, even if setMinimumGCTime(x) had been called.
This was causing garbage to build up, and then a long emergency collection would cause a spike in frame time for a few frames in a row. This is also why your manual collectgarbage() calls fix the issue.

For 1.1.1 I’ve modified this so that games that are using setRefreshRate(0) will get a hard-minimum GC time as requested by a call to setMinimumGCTime(x). I think this feels a bit more true to the API definitions, and probably developer expectations as well.


Music to my ears!

Thank you