What's the meaning of node output with --trace-gc argument?

3,059 views
Skip to first unread message

Mo Cheng

unread,
Jun 1, 2011, 6:45:12 AM6/1/11
to nod...@googlegroups.com
What's the exact meaning of "Scavenge" and "Mark-sweep" and the following memory and time measurements?
It seems this is not documented.


Scavenge 2.6 -> 2.2 MB, 0 ms.

Server running on port 1337

Mark-sweep 3.5 -> 2.7 MB, 3 ms.

Scavenge 3.8 -> 3.1 MB, 0 ms.

Scavenge 5.0 -> 3.6 MB, 0 ms.

Scavenge 5.3 -> 4.0 MB, 1 ms.

Scavenge 5.8 -> 4.5 MB, 0 ms.

Scavenge 6.2 -> 4.9 MB, 0 ms.

Mark-sweep 8.9 -> 2.6 MB, 4 ms.

Scavenge 7.0 -> 3.9 MB, 1 ms.

Scavenge 7.2 -> 4.7 MB, 1 ms.

Scavenge 8.3 -> 5.7 MB, 1 ms.

Mark-sweep 9.2 -> 2.7 MB, 4 ms.

Scavenge 11.3 -> 5.0 MB, 2 ms.

Scavenge 11.7 -> 6.8 MB, 3 ms.

Vyacheslav Egorov

unread,
Jun 1, 2011, 7:31:01 AM6/1/11
to nod...@googlegroups.com
Scavenge|Mark-sweep is a type of collector used by V8.

X -> Y MB means: size of the heap (total size of the objects) before
collection was X and it became Y after collection.

T ms. --- how long GC pause was.

Scavenge is basically a Cheney copying collector with two semispaces
(http://en.wikipedia.org/wiki/Cheney's_algorithm). Used for partial
collections in the young space.

MarkSweep is a classical mark-sweep collector
(http://en.wikipedia.org/wiki/Garbage_collection_(computer_science)#Na.C3.AFve_mark-and-sweep)
used for full collections.

--
Vyacheslav Egorov

> --
> You received this message because you are subscribed to the Google Groups
> "nodejs" group.
> To post to this group, send email to nod...@googlegroups.com.
> To unsubscribe from this group, send email to
> nodejs+un...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en.
>

ambert ho

unread,
Jun 1, 2011, 12:56:48 PM6/1/11
to nod...@googlegroups.com
If you want to read up a bit on garbage collection, so you know what's happening with your allocations under the hood, first a bit of intro reading/lecture, which gives the simple case (mark and sweep) and then gets into the generational GC that the JVM uses:

http://www.cs.berkeley.edu/~jrs/61b/lec/40
And then from Google I/O a couple of years ago, a presentation with visuals on V8's GC:

Ambert

ambert ho

unread,
Jun 1, 2011, 2:45:49 PM6/1/11
to nod...@googlegroups.com
O and fyi Cheney's algorithm which Vyacheslav mentions in the previous reply, is the copying GC mentioned in the notes

Mo Cheng

unread,
Jun 1, 2011, 10:04:49 PM6/1/11
to nod...@googlegroups.com
Thank you, Vyacheslav and Ambert.

It is interesting to find that V8 has two types of GC approaches. Now, I'm wondering how V8 determines which approach to use at run time. 



-Morgan

Vyacheslav Egorov

unread,
Jun 2, 2011, 3:20:42 AM6/2/11
to nod...@googlegroups.com
Simple explanation: if one of old spaces overflowed it uses full
collection, otherwise it uses partial collection.
--
Vyacheslav Egorov
Reply all
Reply to author
Forward
0 new messages