4

I ran my app with the --trace_gc flag to attempt to find some performance issues. Well, it looks like I might have found it...

 1288678 ms: Mark-sweep 498.8 (549.0) -> 488.8 (548.0) MB, 4085 ms [idle notification: finalize idle round] [GC in old space requested].

Gadzooks! More than 4 seconds to do GC. No wonder I'm having issues.

Now, the real question: how can I find what objects are being GC'd, and more importantly, where they were allocated? I've already used heap snapshots in nodetime, but I'm not seeing enough information to help me discover where these objects are coming from. I do see some hints that lead me to believe, perhaps, that I have a cyclic-reference somewhere (eg, I see hundreds of "user" properties in the heap snapshot after just a couple API calls by a single user).

Are there any good tutorials out there or other good information about how to trace the cause of these large garbage collection times? Or maybe I could print the allocated objects somehow, to try to find a cyclic reference...?

Zane Claes
  • 14,732
  • 15
  • 74
  • 131

1 Answers1

3

There are not really any tools for this, but I can assure you that cyclic references are not the problem.

I wonder which version of V8 you are using.

One thing that can cause long pauses is very large objects. V8 is not yet very good at incrementalizing the scanning of multi-million element arrays or objects with hundreds of thousands of objects.

You may want to switch off idle notifications in node or with --nouse-idle-notification. I am not sure the notifications are always firing at the right time. They can tell V8 that the VM has nothing to do and now would be a good time to do non-incremental stop-the-world GC.

Erik Corry
  • 650
  • 4
  • 7
  • I have the latest node.js version (0.8.12), so I assume V8 is up-to-date. Do I understand correctly that turning off idle notifications would prevent the stop-the-world GC from happening when the app has been idle for some time? If so, should I be aware of any major downsides to this before implementing (eg, should I implement manual GC to compensate)? Also, you mentioned turning them off within node, rather than with a flag... how is this done? – Zane Claes Oct 15 '12 at 16:38