PersistentBase::MarkIndependent()

117 views
Skip to first unread message

Jane Chen

unread,
Apr 17, 2015, 3:19:05 PM4/17/15
to v8-u...@googlegroups.com
On v8 3.24:

  /**
   * 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.
   */
  V8_INLINE void MarkIndependent();

I'd like to understand the above better.  In what kind of scenario do I want to mark a persistent handle independent?  What kind of impact does it have on GC?

Thanks!

tbl...@icloud.com

unread,
Oct 1, 2016, 12:36:43 AM10/1/16
to v8-users
Anybody know the answer to this? (bump)

Ben Noordhuis

unread,
Oct 1, 2016, 4:33:41 AM10/1/16
to 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.
Reply all
Reply to author
Forward
0 new messages