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, 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".
10-10 00:27:34.140: INFO/v8(32656): ?D?? 6351031365587755522057220257292374326212763523190095872.0 -> -0.0 MB,
10-10 00:27:34.140: INFO/v8(32656): 1263571892 ms.
10-10 00:27:34.140: INFO/v8(32656): Memory allocator, used: 1263571876, available: -2118013160
10-10 00:27:34.140: INFO/v8(32656): New space, used: 1263571876, available: -2118013160
10-10 00:27:34.140: INFO/v8(32656): Old pointers, used: 1263571876, available: -2118013160, waste: 1263571876
10-10 00:27:34.140: INFO/v8(32656): Old data space, used: 1263571876, available: -2118013160, waste: 1263571876
10-10 00:27:34.140: INFO/v8(32656): Code space, used: 1263571876, available: -2118013160, waste: 1263571876
10-10 00:27:34.140: INFO/v8(32656): Map space, used: 1263571876, available: -2118013160, waste: 1263571876
10-10 00:27:34.140: INFO/v8(32656): Cell space, used: 1263571876, available: -2118013160, waste: 1263571876
10-10 00:27:34.140: INFO/v8(32656): Large object space, used: 1263571892, available: -2118498744
10-10 00:27:34.320: INFO/v8(32656): ?D?? 6350937828500622873889477860090764425384320345802014720.0 -> -0.0 MB,
10-10 00:27:34.320: INFO/v8(32656): 1263571876 ms.
10-10 00:27:34.320: INFO/v8(32656): Memory allocator, used: 1263571860, available: -2118013160
10-10 00:27:34.320: INFO/v8(32656): New space, used: 1263571860, available: -2118013160
10-10 00:27:34.320: INFO/v8(32656): Old pointers, used: 1263571860, available: -2118013160, waste: 1263571860
10-10 00:27:34.320: INFO/v8(32656): Old data space, used: 1263571860, available: -2118013160, waste: 1263571860
10-10 00:27:34.320: INFO/v8(32656): Code space, used: 1263571860, available: -2118013160, waste: 1263571860
10-10 00:27:34.320: INFO/v8(32656): Map space, used: 1263571860, available: -2118013160, waste: 1263571860
10-10 00:27:34.320: INFO/v8(32656): Cell space, used: 1263571860, available: -2118013160, waste: 1263571860
10-10 00:27:34.320: INFO/v8(32656): Large object space, used: 1263571876, available: -2118498744