课程: Java Memory Management: Garbage Collection, JVM Tuning, and Spotting Memory Leaks

今天就学习课程吧!

今天就开通帐号,24,700 门业界名师课程任您挑!

Garbage collection phase: Marking

Garbage collection phase: Marking

- [Narrator] So imagine we're having a heap full of objects that leave out the Java garbage collector for a while here, and try to think like garbage collectors ourselves. So how are we going to find out which objects don't have a connection to the stack? Well, here's the stack, and for now for just a second, pause this video and pretend to be the garbage collector. How to find out which ones don't have a connection. Frankly, we cannot do this in one step. We'll first have to sort out which ones do have a connection to the stack, and if we have identified all the reference on the stack, we know which objects have a connection to the stack. Next, we're going to see what references of these objects are, and also these objects have reference to the stack, indirectly. We repeat this until we have checked all the nested references, and then we know what objects have a connection to the stack. And with that knowledge we also know what objects don't have a connection to the stack. Namely…

内容