What is object graph in java?

前端 未结 6 1045
轮回少年
轮回少年 2020-12-28 13:54

Whenever I study Garbage Collector I hear the term object Graph. What does it mean exactly?

6条回答
  •  情话喂你
    2020-12-28 14:34

    Objects have references to other objects which may in turn have references to more objects including the starting object. This creates a graph of objects, useful in reachability analysis. For instance, if the starting object is reachable (say it's in a thread's local stack) then all objects in the graph are reachable and an exact garbage collector cannot harvest any of these objects. Similarly, starting with a set of live objects (roots) if we create a list of all reachable objects, all other objects are garbage - fair game for collection.

提交回复
热议问题