Package org.eclipse.mat.snapshot.model

## Class GCRootInfo

- java.lang.Object
- - org.eclipse.mat.snapshot.model.GCRootInfo

All Implemented Interfaces:
  `java.io.Serializable`

Direct Known Subclasses:
  `XGCRootInfo`

    public abstract class GCRootInfo
    extends java.lang.Object
    implements java.io.Serializable

Describes a garbage collection root.

See Also:
  Serialized Form

### Nested Class Summary

Nested Classes
`static interface` `GCRootInfo.Type` Reasons why an heap object is a garbage collection root.

### Constructor Summary

Constructors
`GCRootInfo​(long objectAddress, long contextAddress, int type)` Create a description of a Garbage Collection root

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`long` `getContextAddress()` The object address of the source of the root
`int` `getContextId()` The object id of the source of the root, if there is a source
`long` `getObjectAddress()` The object address of the retained object
`int` `getObjectId()` The object id of the retained object
`int` `getType()` The reason for the root
`static java.lang.String` `getTypeAsString​(int type)` A printable version of the type
`static java.lang.String` `getTypeSetAsString​(GCRootInfo[] roots)` A combined representation of the types of several roots.

### Methods inherited from class java.lang.Object

`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### GCRootInfo

    public GCRootInfo​(long objectAddress,
                      long contextAddress,
                      int type)

Create a description of a Garbage Collection root

Parameters:
  `objectAddress` - the object which is retained
  `contextAddress` - the source of the retention - e.g. a thread address, or 0 for none
  `type` - the reason the object is retained `GCRootInfo.Type`

### Method Detail

#### getObjectId

    public int getObjectId()

The object id of the retained object

Returns:
  the target object

#### getObjectAddress

    public long getObjectAddress()

The object address of the retained object

Returns:
  the target object address

#### getContextAddress

    public long getContextAddress()

The object address of the source of the root

Returns:
  the source object address, or 0 if none

#### getContextId

    public int getContextId()

The object id of the source of the root, if there is a source

Returns:
  the source object id

#### getType

    public int getType()

The reason for the root

Returns:
  A number representing the type as `GCRootInfo.Type`

#### getTypeAsString

    public static java.lang.String getTypeAsString​(int type)

A printable version of the type

Parameters:
  `type` - as `GCRootInfo.Type`
Returns:
  the printable version of the type
See Also:
  `GCRootInfo.Type`

#### getTypeSetAsString

    public static java.lang.String getTypeSetAsString​(GCRootInfo[] roots)

A combined representation of the types of several roots. The types are currently separated by commas, but this could change e.g. for NLS reasons?

Parameters:
  `roots` - an array of roots to get the combined type from
Returns:
  A combined type
See Also:
  `GCRootInfo.Type`