Companion

object Companion

Properties

Link copied to clipboard
const val COMPRESSED_REFS_ENABLED: Boolean = false

True, iff compressed references (oops) are enabled by this JVM

Link copied to clipboard

Approximate memory usage that we assign to a Hashtable / HashMap entry.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Approximate memory usage that we assign to a LinkedHashMap entry.

Link copied to clipboard
Link copied to clipboard
const val MAX_DEPTH: Int = 1

Recurse only into immediate descendants.

Link copied to clipboard

Number of bytes to represent an array header (no content, but with alignments).

Link copied to clipboard

A constant specifying the object alignment boundary inside the JVM. Objects will always take a full multiple of this constant, possibly wasting some space.

Link copied to clipboard

Number of bytes to represent an object header (no fields, no alignments).

Link copied to clipboard
const val NUM_BYTES_OBJECT_REF: Int = 4

Number of bytes this JVM uses to represent an object reference.

Link copied to clipboard
const val ONE_GB: Long

One gigabyte bytes.

Link copied to clipboard
const val ONE_KB: Long = 1024

One kilobyte bytes.

Link copied to clipboard
const val ONE_MB: Long

One megabyte bytes.

Link copied to clipboard

Sizes of primitive classes.

Link copied to clipboard

Approximate memory usage that we assign to all unknown queries - this maps roughly to a BooleanQuery with a couple term clauses.

Link copied to clipboard
Link copied to clipboard

Approximate memory usage that we assign to all unknown objects - this maps roughly to a few primitive fields and a couple short String-s.

Functions

Link copied to clipboard
fun adjustForField(sizeSoFar: Long, f: Field): Long

This method returns the maximum representation size of an object. sizeSoFar is the object's size measured so far. f is the field being probed.

Link copied to clipboard

Aligns an object size to be the next multiple of .NUM_BYTES_OBJECT_ALIGNMENT.

Link copied to clipboard

Returns bytes in human-readable units (GB, MB, KB or bytes).

Link copied to clipboard
fun shallowSizeOf(obj: Any?): Long

Estimates a "shallow" memory usage of the given object. For arrays, this will be the memory taken by array storage (no subreferences will be followed). For objects, this will be the memory taken by the fields.

Returns the shallow size in bytes of the Object[] object.

Returns the size in bytes of the boolean[] object.

Returns the size in bytes of the byte[] object.

Returns the size in bytes of the char[] object.

Returns the size in bytes of the double[] object.

Returns the size in bytes of the float[] object.

Returns the size in bytes of the int[] object.

Returns the size in bytes of the long[] object.

Returns the size in bytes of the short[] object.

Link copied to clipboard

Returns the shallow instance size in bytes an instance of the given class would occupy. This works with all conventional classes and primitive types, but not with arrays (the size then depends on the number of elements and varies from object to object).

Link copied to clipboard
fun sizeOf(arr: Array<String>): Long

Returns the size in bytes of the String[] object.

@JvmName(name = "sizeOfAccountableNullable")
fun sizeOf(accountables: Array<Accountable?>): Long

Return the size of the provided array of Accountables by summing up the shallow size of the array and the memory usage reported by each [ ].

fun sizeOf(accountables: Array<Accountable>): Long

Returns the size in bytes of the boolean[] object.

fun sizeOf(arr: ByteArray): Long

Returns the size in bytes of the byte[] object.

fun sizeOf(arr: CharArray): Long

Returns the size in bytes of the char[] object.

Returns the size in bytes of the double[] object.

Returns the size in bytes of the float[] object.

fun sizeOf(ignored: Int): Long

Return the shallow size of the provided Integer object. Ignores the possibility that this object is part of the VM IntegerCache

fun sizeOf(arr: IntArray): Long

Returns the size in bytes of the int[] object.

fun sizeOf(ignored: Long): Long

Return the shallow size of the provided Long object. Ignores the possibility that this object is part of the VM LongCache

fun sizeOf(arr: LongArray): Long

Returns the size in bytes of the long[] object.

Returns the size in bytes of the short[] object.

fun sizeOf(s: String?): Long

Returns the size in bytes of the String object.

fun sizeOf(q: Query): Long

Returns the size in bytes of a Query object. Unknown query types will be estimated as .QUERY_DEFAULT_RAM_BYTES_USED.

fun sizeOf(accountable: Accountable): Long

Returns the size in bytes of the Accountable object, using its method.

fun sizeOf(q: Query, defSize: Long): Long

Returns the size in bytes of a Query object. Unknown query types will be estimated using .shallowSizeOf, or using the supplied defSize parameter if its value is greater than 0.

Link copied to clipboard
fun sizeOfCollection(collection: Collection<*>?): Long

Returns the size in bytes of a Collection object, including sizes of its values, supplying .UNKNOWN_DEFAULT_RAM_BYTES_USED when object type is not well known. This method recurses up to .MAX_DEPTH.

fun sizeOfCollection(collection: Collection<*>?, defSize: Long): Long

Returns the size in bytes of a Collection object, including sizes of its values, supplying default object size when object type is not well known. This method recurses up to .MAX_DEPTH.

Link copied to clipboard
fun sizeOfMap(map: Map<*, *>?): Long

Returns the size in bytes of a Map object, including sizes of its keys and values, supplying .UNKNOWN_DEFAULT_RAM_BYTES_USED when object type is not well known. This method recurses up to .MAX_DEPTH.

fun sizeOfMap(map: Map<*, *>?, defSize: Long): Long

Returns the size in bytes of a Map object, including sizes of its keys and values, supplying default object size when object type is not well known. This method recurses up to .MAX_DEPTH.

Link copied to clipboard

Best effort attempt to estimate the size in bytes of an undetermined object. Known types will be estimated according to their formulas, and all other object sizes will be estimated as .UNKNOWN_DEFAULT_RAM_BYTES_USED.

fun sizeOfObject(o: Any?, defSize: Long): Long

Best effort attempt to estimate the size in bytes of an undetermined object. Known types will be estimated according to their formulas, and all other object sizes will be estimated using .shallowSizeOf, or using the supplied defSize parameter if its value is greater than 0.