HeapInstance

class HeapInstance : HeapObject

An instance in the heap dump.

Functions

Link copied to clipboard
operator fun get(declaringClassName: String, fieldName: String): HeapField?
operator fun get(declaringClass: KClass<out Any>, fieldName: String): HeapField?
Link copied to clipboard
infix fun instanceOf(className: String): Boolean

Returns true if this is an instance of the class named className or an instance of a subclass of that class.

infix fun instanceOf(expectedClass: KClass<*>): Boolean
infix fun instanceOf(expectedClass: HeapObject.HeapClass): Boolean

Returns true if this is an instance of expectedClass or an instance of a subclass of that class.

Link copied to clipboard
fun readAsJavaString(): String?

If this HeapInstance is an instance of the String class, returns a String instance with content that matches the string in the heap dump. Otherwise returns null.

Link copied to clipboard
fun readField(declaringClassName: String, fieldName: String): HeapField?

Returns a HeapField object that reflects the specified declared field of the instance represented by this HeapInstance object, or null if this field does not exist. The declaringClassName specifies the class in which the desired field is declared, and the fieldName parameter specifies the simple name of the desired field.

fun readField(declaringClass: KClass<out Any>, fieldName: String): HeapField?
Link copied to clipboard
fun readFields(): Sequence<HeapField>

The fields of this instance, as a sequence of HeapField.

Link copied to clipboard
open override fun readRecord(): HprofRecord.HeapDumpRecord.ObjectRecord.InstanceDumpRecord

Reads and returns the underlying InstanceDumpRecord.

Link copied to clipboard
open override fun toString(): String

Properties

Link copied to clipboard
val asClass: HeapObject.HeapClass?

This HeapObject as a HeapClass if it is one, or null otherwise

Link copied to clipboard
val asInstance: HeapObject.HeapInstance?

This HeapObject as a HeapInstance if it is one, or null otherwise

Link copied to clipboard
val asObjectArray: HeapObject.HeapObjectArray?

This HeapObject as a HeapObjectArray if it is one, or null otherwise

Link copied to clipboard
val asPrimitiveArray: HeapObject.HeapPrimitiveArray?

This HeapObject as a HeapPrimitiveArray if it is one, or null otherwise

Link copied to clipboard
val byteSize: Int
Link copied to clipboard
open override val graph: HeapGraph

The graph of objects in the heap, which you can use to navigate the heap.

Link copied to clipboard
val instanceClass: HeapObject.HeapClass

The class of this instance.

Link copied to clipboard
val instanceClassId: Long

The heap identifier of the class of this instance.

Link copied to clipboard
val instanceClassName: String

The name of the class of this instance, identical to Class.getName.

Link copied to clipboard
val instanceClassSimpleName: String

Returns instanceClassName stripped of any string content before the last period (included).

Link copied to clipboard
val isPrimitiveWrapper: Boolean

Whether this is an instance of a primitive wrapper type.

Link copied to clipboard
open override val objectId: Long

The heap identifier of this object.

Link copied to clipboard
open override val objectIndex: Int

An positive object index that's specific to how Shark stores objects in memory. The index starts at 0 and ends at HeapGraph.objectCount - 1. There are no gaps, every index value corresponds to an object. Classes are first, then instances, then object arrays then primitive arrays.

Link copied to clipboard
val positiveObjectId: Long

objectId masked to be a positive unique identifier, as reported in Android Studio.

Link copied to clipboard
open override val recordSize: Int

The total byte size for the record of this object in the heap dump.