We're running a game engine natively on Android using v8. It works fine, except that garbage collection causes periodic hesitations (pauses) in display. I'm using the AddGCPrologueCallback() & AddGCEpilogueCallback() to log the gc. The Scavenge type gc does not cause a problem, only the MarkSweepCompact type. The way it happens depends on the number of active entities in the game. With few entities we get MSC type GC every minute or so, and no visible hesitation. But with high number of entities, MSC happens every 4-5 seconds, and visually estimating, it looks like pause periods of 100-300mS. Are there any options to change GC behavior to avoid this problem? I've tried " --max-new-space-size=1024 --never-compact" flags based on suggestion by Erik Cory in this stack overflow question<http://stackoverflow.com/questions/5603011/node-js-and-v8-garbage-col...>, but it still behaves the same.
Thanks for your help.
------------
Some more info:
I'm measuring the period between Prologue and Epilogue callbacks to see how long GC takes. Not sure if this is a good way of measuring or not. For some reason with low entity numbers, where there's no visible hesitation, the GC time measures 30-100 mS. But with high entity numbers, where the pause is noticable, the GC time measures about 17 mS.
I'm using V8 version 3.9.21.
Below, I've pasted some GC log info through setting "--trace-gc-verbose --trace-gc".
An update on this for anybody who might have a similar issue and find this post:
The GC problems observed were actually happening with an older version of V8. Switching to version 3.9.21 fixed the issues, and in this version --max-new-space-size=1024 --never-compact actually work and make a difference. Thanks V8 team.
On Wednesday, October 10, 2012 10:43:27 AM UTC-7, Shalay wrote:
> Hello,
> We're running a game engine natively on Android using v8. It works fine, > except that garbage collection causes periodic hesitations (pauses) in > display. I'm using the AddGCPrologueCallback() & AddGCEpilogueCallback() > to log the gc. The Scavenge type gc does not cause a problem, only the > MarkSweepCompact type. > The way it happens depends on the number of active entities in the game. > With few entities we get MSC type GC every minute or so, and no visible > hesitation. But with high number of entities, MSC happens every 4-5 > seconds, and visually estimating, it looks like pause periods of > 100-300mS. Are there any options to change GC behavior to avoid this > problem? I've tried " --max-new-space-size=1024 --never-compact" flags > based on suggestion by Erik Cory in this stack overflow question<http://stackoverflow.com/questions/5603011/node-js-and-v8-garbage-col...>, > but it still behaves the same.
> Thanks for your help.
> ------------
> Some more info:
> I'm measuring the period between Prologue and Epilogue callbacks to see > how long GC takes. Not sure if this is a good way of measuring or not. > For some reason with low entity numbers, where there's no visible > hesitation, the GC time measures 30-100 mS. But with high entity numbers, > where the pause is noticable, the GC time measures about 17 mS.