HeapInstance

class HeapInstance : HeapObject

An instance in the heap dump.

Functions

get
Link copied to clipboard
operator fun get(declaringClassName: String, fieldName: String): HeapField?
operator fun get(declaringClass: KClass<out Any>, fieldName: String): HeapField?
instanceOf
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.

readAsJavaString
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.

readField
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?
readFields
Link copied to clipboard
fun readFields(): Sequence<HeapField>

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

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

Reads and returns the underlying InstanceDumpRecord.

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

Properties

asClass
Link copied to clipboard
val asClass: HeapObject.HeapClass?

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

asInstance
Link copied to clipboard
val asInstance: HeapObject.HeapInstance?

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

asObjectArray
Link copied to clipboard
val asObjectArray: HeapObject.HeapObjectArray?

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

asPrimitiveArray
Link copied to clipboard
val asPrimitiveArray: HeapObject.HeapPrimitiveArray?

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

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

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

instanceClass
Link copied to clipboard
val instanceClass: HeapObject.HeapClass

The class of this instance.

instanceClassId
Link copied to clipboard
val instanceClassId: Long

The heap identifier of the class of this instance.

instanceClassName
Link copied to clipboard
val instanceClassName: String

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

instanceClassSimpleName
Link copied to clipboard
val instanceClassSimpleName: String

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

isPrimitiveWrapper
Link copied to clipboard
val isPrimitiveWrapper: Boolean

Whether this is an instance of a primitive wrapper type.

objectId
Link copied to clipboard
open override val objectId: Long

The heap identifier of this object.

objectIndex
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.

positiveObjectId
Link copied to clipboard
val positiveObjectId: Long

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

recordSize
Link copied to clipboard
open override val recordSize: Int

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