You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Those are "ROOTS" (the ones with type = "ROOTS"). The system has various "roots".
What is a "ROOT"?
Objects in the system form a tree data structure. Imagine some code like this:
a="foo"b="bar"c={a=>b}
It's easy to see how c is connected to a and b and prevents them from being garbage collected:
But say we have this:
a="foo"b="bar"c={a=>b}GC.startpc
What prevents c from being garbage collected? Something must hold a reference to c so that the garbage collector can know that it shouldn't be GC'd. This is where ROOTS come in. Roots are special nodes in the system that hold on to these references:
MRI has a few different places it considers a root, and those are in the name root (like vm, finalizers, etc). Explaining each of these types is a little too long for here, but you can think of them as the root of the tree that forms your object graph. They keep your program objects alive, and they are the starting point for the GC to find live objects in your system. In fact the graph I showed above is a little inaccurate. Since a and b are also top level local variables like c, the graph looks a bit more like this:
Hope that helps!
The text was updated successfully, but these errors were encountered:
Those are "ROOTS" (the ones with type = "ROOTS"). The system has various "roots".
What is a "ROOT"?
Objects in the system form a tree data structure. Imagine some code like this:
It's easy to see how
c
is connected toa
andb
and prevents them from being garbage collected:But say we have this:
What prevents
c
from being garbage collected? Something must hold a reference toc
so that the garbage collector can know that it shouldn't be GC'd. This is where ROOTS come in. Roots are special nodes in the system that hold on to these references:MRI has a few different places it considers a root, and those are in the name
root
(likevm
,finalizers
, etc). Explaining each of these types is a little too long for here, but you can think of them as the root of the tree that forms your object graph. They keep your program objects alive, and they are the starting point for the GC to find live objects in your system. In fact the graph I showed above is a little inaccurate. Sincea
andb
are also top level local variables likec
, the graph looks a bit more like this:Hope that helps!
The text was updated successfully, but these errors were encountered: