Skip to content
🤔 Documentation issue? Report it

//leakcanary-repo/shark/HeapObject/HeapInstance

HeapInstance

[jvm]\ class HeapInstance : HeapObject

An instance in the heap dump.

Functions

Name Summary
get [jvm]
operator fun get(declaringClassName: String, fieldName: String): HeapField?
operator fun get(declaringClass: KClass<out Any>, fieldName: String): HeapField?
instanceOf [jvm]
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.
[jvm]
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 [jvm]
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 [jvm]
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.
[jvm]
fun readField(declaringClass: KClass<out Any>, fieldName: String): HeapField?
readFields [jvm]
fun readFields(): Sequence<HeapField>
The fields of this instance, as a sequence of HeapField.
readRecord [jvm]
open override fun readRecord(): HprofRecord.HeapDumpRecord.ObjectRecord.InstanceDumpRecord
Reads and returns the underlying InstanceDumpRecord.
toString [jvm]
open override fun toString(): String

Properties

Name Summary
asClass [jvm]
val asClass: HeapObject.HeapClass?
This HeapObject as a HeapClass if it is one, or null otherwise
asInstance [jvm]
val asInstance: HeapObject.HeapInstance?
This HeapObject as a HeapInstance if it is one, or null otherwise
asObjectArray [jvm]
val asObjectArray: HeapObject.HeapObjectArray?
This HeapObject as a HeapObjectArray if it is one, or null otherwise
asPrimitiveArray [jvm]
val asPrimitiveArray: HeapObject.HeapPrimitiveArray?
This HeapObject as a HeapPrimitiveArray if it is one, or null otherwise
byteSize [jvm]
val byteSize: Int
graph [jvm]
open override val graph: HeapGraph
The graph of objects in the heap, which you can use to navigate the heap.
hexIdentityHashCode [jvm]
val HeapObject.HeapInstance.hexIdentityHashCode: String?
The system identity hashCode represented as hex, or null if it couldn’t be found. This is the string identifier you see when calling Object.toString() at runtime on a class that does not override its hashCode() method, e.g. com.example.MyThing@6bd57cf
identityHashCode [jvm]
val HeapObject.HeapInstance.identityHashCode: Int?
The system identity hash code, or null if it couldn’t be found.
instanceClass [jvm]
val instanceClass: HeapObject.HeapClass
The class of this instance.
instanceClassId [jvm]
val instanceClassId: Long
The heap identifier of the class of this instance.
instanceClassName [jvm]
val instanceClassName: String
The name of the class of this instance, identical to Class.getName.
instanceClassSimpleName [jvm]
val instanceClassSimpleName: String
Returns instanceClassName stripped of any string content before the last period (included).
isPrimitiveWrapper [jvm]
val isPrimitiveWrapper: Boolean
Whether this is an instance of a primitive wrapper type.
objectId [jvm]
open override val objectId: Long
The heap identifier of this object.
objectIndex [jvm]
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 [jvm]
val positiveObjectId: Long
objectId masked to be a positive unique identifier, as reported in Android Studio.
recordSize [jvm]
open override val recordSize: Int
The total byte size for the record of this object in the heap dump.