Questions tagged [gc-roots]

Root collection in tracing garbage collection algorithms

For questions related to the methods and algorithms tracing garbage collectors use to find root nodes to begin their scan of the heap. Like creating gc maps, visiting activation records, local variables and so on.

16 questions
71
votes
5 answers

What are the roots?

What are the roots in garbage collection? I have read the definition of root as "any reference that you program can access to" and definition of live is that an object that is being used, which can be a local variable, static variable. I m little…
DarthVader
  • 52,984
  • 76
  • 209
  • 300
62
votes
9 answers

Is the stack garbage collected in Java?

The heap memory is garbage collected in Java. Is the stack garbage collected as well? How is stack memory reclaimed?
giri
  • 26,773
  • 63
  • 143
  • 176
10
votes
3 answers

Thread as a GC root

I have a question about GC roots. I read that one of the GC roots is "Live thread". What does that mean? I always had the impression that each thread has its own stack and local variables of a stack are GC roots for thread, and now I'm confused.…
alobodzk
  • 1,284
  • 2
  • 15
  • 27
7
votes
2 answers

How to find gc roots in a stack machine?

I am writing a compiler for a fairly standard stack machine. Now I want to add a garbage collector. I can see that I could generate some sort of 'stack maps' to know which variables are gc roots in each activation record. However, I have no idea how…
6
votes
2 answers

Finding roots for garbage collection in C

I'm trying to implement a simple mark and sweep garbage collector in C. The first step of the algorithm is finding the roots. So my question is how can I find the roots in a C program? In the programs using malloc, I'll be using the custom…
questions
  • 2,337
  • 4
  • 24
  • 39
5
votes
2 answers

How does garbage collector identify roots

The first phase of a mark-sweep garbage collector is to mark(find) all the live objects on the heap. To do this, there must be a starting point or root, from where all the marking begins. How does GC identify such roots?
Chander Shivdasani
  • 9,878
  • 20
  • 76
  • 107
5
votes
2 answers

Why does a non-static field not act as a GC root?

As I know static fields (along with Threads, local variables and method arguments, JNI references) act as GC roots. I cannot provide a link that would confirm this, but I have read a lot of articles on it. Why can't a non-static field act as a GC…
gstackoverflow
  • 36,709
  • 117
  • 359
  • 710
4
votes
2 answers

GC roots and local variables

While looking at the Timer documentation I ran across the following example with this comment: // Normally, the timer is declared at the class level, // so that it stays in scope as long as it is needed. // If the timer is declared in a…
Voo
  • 29,040
  • 11
  • 82
  • 156
3
votes
1 answer

card table and write barriers in .net GC

Can anybody explain the concept of card table and write barriers in Garbage Collection process in .Net? I really can't get the explanation of these terms i.e what are they,how are they useful and how do they paticipate in GC. Any help would be…
maverickabhi
  • 197
  • 1
  • 6
  • 21
2
votes
1 answer

JProfiler Heap Walker - select objects that are held by GC Root located in specific Java packages

I have JavaFX application and I have made Heap Snaphot using JProfiler 10.1.5. My current object set (filtered using "use new" selection step) has 46064 objects in 672 classes. I would like to narrow the search range for memory leaks, and filter my…
sgnsajgon
  • 664
  • 2
  • 13
  • 56
1
vote
1 answer

How are garbage collector (GC) roots stored?

I know how roots are found, but the thing is, (AFAIK) they have to be found at runtime. For that, you'll need a fixed size container that may overflow or a resizable container. I don't want to go with the fixed size container because it would not be…
1
vote
1 answer

What is/are GC root objects referencing Java outer and inner classes?

So I did tons of research regarding memory leaks in android and have read many StackOverflow posts. What I still don't understand is that according to Medium and StackOverflow posts (links mentioned below), If I pass my activity's context to an…
1
vote
0 answers

Zookeeper: why instances of ClientCnxn are GC roots in MAT?

I'm looking into heap dump with Eclipse MAT and yet can not grasp why zookeeper ClientCnxn instances are marked as GC roots there. This class is loaded by application classloader under Websphere AS. And I see quite a lot of these instances…
0
votes
0 answers

Why does my gcroot output have so many weird things in it?

I'm having trouble finding good documentation for the gcroot command as it applies to .NET core code so it's making it hard to follow some very weird gcroot output I have. Below you'll see the top part of the output I'm talking about and the very…
Shane Courtrille
  • 13,960
  • 22
  • 76
  • 113
0
votes
1 answer

GC roots in IBM java heapdump - is the list complete?

I'm analyzing .phd dump written by IBM JVM with Eclipse MAT. The view named "gc_roots" displays the following list: Can I be sure that the list of GC roots is complete? Does it mean all local variables in stack of running threads are included in…
user3714601
  • 1,156
  • 9
  • 27
1
2