Interface IPathsFromGCRootsComputer


public interface IPathsFromGCRootsComputer
Interface describing an interactive computer for paths from GC roots to an object. You will get such a computer from the ISnapshot API.

Finding paths from GC roots to an object is handy if you want to learn which objects are responsible for the given object to remain in memory. Since the snapshot implementation artificially creates references from the object to its class and from the class to its class loader you can even see why a class or class loader remains in memory, i.e. which other objects hold references to objects of the class or class loader of interest.

No Implement:
  • Method Summary

    Modifier and Type
    Method
    Description
    int[]
    Get next shortest path.
    getTree(Collection<int[]> paths)
    Helper method constructing a tree like data structure from the given paths.
  • Method Details

    • getNextShortestPath

      int[] getNextShortestPath() throws SnapshotException
      Get next shortest path. The computer holds the state of the computation and allows to continuously ask for the next path. If null is returned no path is available anymore.

      This method allows you either to ask for all paths (which could take quite some time and memory but shows you the complete picture) or one by one (the shortest paths are returned first; more useful in an UI as a user might find a problem faster among just a few shorter paths).

      Returns:
      int array holding the object ids of the objects forming the path from the first element at index 0 (object for which the computation was started) to the last element in the int array (object identified as GC root)
      Throws:
      SnapshotException
    • getTree

      PathsFromGCRootsTree getTree(Collection<int[]> paths)
      Helper method constructing a tree like data structure from the given paths. Either all so far collected paths could be dropped in here or just the last ones if you want to limit the view.
      Parameters:
      paths - paths from GC roots previously returned by getNextShortestPath()
      Returns:
      tree like data structure holding the paths from GC roots