gc-roots

card table and write barriers in .net GC

那年仲夏 提交于 2020-01-15 03:57:05
问题 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 really appreciated. 回答1: The card table is an array of bits, one bit for each chunk of 256 bytes of memory in the old generation. The bits are normally zero but when a field of an object in the old generation is written to, the bit corresponding to the

GC roots and local variables

倖福魔咒の 提交于 2019-12-10 17:39:24
问题 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 long-running method, // KeepAlive must be used to prevent the JIT compiler // from allowing aggressive garbage collection to occur // before the method ends. You can experiment with this // by commenting out the class-level declaration and // uncommenting the

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

谁说我不能喝 提交于 2019-12-04 12:36:44
问题 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 root? 回答1: First off, we need to be sure we're on the same page as to what a tracing garbage collection algorithm does in its mark phase. At any given moment, a tracing GC has a number of objects that are known to be alive, in the sense that they are

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

喜欢而已 提交于 2019-12-03 08:22:48
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 root? First off, we need to be sure we're on the same page as to what a tracing garbage collection algorithm does in its mark phase. At any given moment, a tracing GC has a number of objects that are known to be alive, in the sense that they are reachable by the running program as it stands right now. The main step of mark phrase involves following

Is the stack garbage collected in Java?

别等时光非礼了梦想. 提交于 2019-11-28 16:57:43
The heap memory is garbage collected in Java. Is the stack garbage collected as well? How is stack memory reclaimed? Mnementh The memory on the stack contains method-parameters and local variables (to be precise: the references for objects and variables itself for primitive types). That will be automatically removed if you leave the method. If the variables are references (to objects) the objects itself are on the heap and handled by the garbage collector. So the stack isn't garbage collected in the same way as the heap, but stack is a form of automatic memory-management in it's own (which

Is the stack garbage collected in Java?

左心房为你撑大大i 提交于 2019-11-27 09:56:50
问题 The heap memory is garbage collected in Java. Is the stack garbage collected as well? How is stack memory reclaimed? 回答1: The memory on the stack contains method-parameters and local variables (to be precise: the references for objects and variables itself for primitive types). That will be automatically removed if you leave the method. If the variables are references (to objects) the objects itself are on the heap and handled by the garbage collector. So the stack isn't garbage collected in

What are the roots?

泄露秘密 提交于 2019-11-26 02:18:36
问题 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 confused with discriminating the difference between root and live objects. What is path to root? How does root and live objects work? Can someone elaborate ? 回答1: If you think of the objects in memory as a tree, the "roots" would be the root nodes