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

今天就学习课程吧!

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

Solution: Eligible for garbage collection

Solution: Eligible for garbage collection

(upbeat music) - [Instructor] Your job was to mark the objects eligible for garbage collection, and here's how to do that. On line 23, it's indicating that it is done processing, so after that, we no longer need to keep the object. So in this case, we implemented the release object by setting it to null. There's no use for calling System.gc. That's not marking it for garbage collection. What is marking it for garbage collection is when it's no longer having a relation to the heap, and here we're doing that by setting the reference that we're having to null. So if I go ahead and run this code, you can see that it validates, and it's saying you did it. The result is exactly right.

内容