Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

v8::Persistent MarkIndependent, what does this method exactly do?

Following is v8 code comment, I don't quite understand explaination.

/**
 * Marks the reference to this object independent. Garbage collector
 * is free to ignore any object groups containing this object.
 * Weak callback for an independent handle should not
 * assume that it will be preceded by a global GC prologue callback
 * or followed by a global GC epilogue callback.
 */
inline void MarkIndependent();
inline void MarkIndependent(Isolate* isolate);
like image 591
Kevin Avatar asked May 24 '13 09:05

Kevin


1 Answers

From a post on v8-users:

I think the exact meaning of 'independent' has shifted a little since 3.24. Here is my understanding of what it does in recent versions of V8:

  1. It avoids the cost of object group handling. We don't use object groups in node.js but I think chromium does for DOM objects; if one DOM object in the collection is alive, then logically all are. Defining an object group lets the garbage collector take a shortcut at a cost of some processing overhead per individual handle.

  2. Independent handles can be reclaimed during minor garbage collections (scavenges). Dependent handles are only reclaimed during major collections and thus remain alive longer, which is usually undesirable; I think they only become eligible for collection once the object they point to has been promoted from the new space (the nursery) to the old space.

like image 133
tbodt Avatar answered Oct 22 '22 00:10

tbodt