Package org.eclipse.mat.snapshot.model

# Class GCRootInfo

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

All Implemented Interfaces:
  `Serializable`

Direct Known Subclasses:
  `XGCRootInfo`

public abstract class GCRootInfo extends Object implements Serializable
Describes a garbage collection root.

See Also:
  - Serialized Form

## Nested Class Summary

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

## Constructor Summary

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

## Method Summary

Modifier and Type
Method
Description
`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 String`
`getTypeAsString(int type)`
A printable version of the type
`static 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 Details

### 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 Details

### 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 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 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`