java.lang.Object
com.s8.api.bytes.MemoryFootprint
A Mmeory footprint object for sampling/forecasting memory usage of some objects in serialization operations.
- Author:
- Pierre Convert Copyright (C) 2025, Pierre Convert. All rights reserved.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longBytecount default for map entrystatic final longProxy of object allocation in RAM: object.static final longBytecount default for object reference -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlongCalculate on the fly the bytecount associated with the reported instances.voidreportBytes(long payload) Report bytes on this memory footprint.voidReport an entry and increment the number of entries of this memory footprint.voidReport an instance and increment the number of instance of this memory footprint.voidreportInstances(int n) Report many instances and increment the number of instance of this memory footprint.voidReport a reference and increment the number of references of this memory footprint.voidreportReferences(int n) Report a reference and increment the number of references of this memory footprint.
-
Field Details
-
OBJECT_ALLOCATION_BYTECOUNT
public static final long OBJECT_ALLOCATION_BYTECOUNTProxy of object allocation in RAM: object. Memory footprint+
From: https://stackoverflow.com/questions/258120/what-is-the-memory-consumption-of-an-object-in-java:
In a modern 64-bit JDK, an object has a 12-byte header, padded to a multiple of 8 bytes, so the minimum object size is 16 bytes. For 32-bit JVMs, the overhead is 8 bytes, padded to a multiple of 4 bytes. (From Dmitry Spikhalskiy's answer, Jayen's answer, and JavaWorld.)- See Also:
-
OBJECT_REFERENCE_BYTECOUNT
public static final long OBJECT_REFERENCE_BYTECOUNTBytecount default for object reference- See Also:
-
ENTRY_BYTECOUNT
public static final long ENTRY_BYTECOUNTBytecount default for map entry- See Also:
-
-
Constructor Details
-
MemoryFootprint
public MemoryFootprint()Default constructor
-
-
Method Details
-
reportInstance
public void reportInstance()Report an instance and increment the number of instance of this memory footprint. -
reportInstances
public void reportInstances(int n) Report many instances and increment the number of instance of this memory footprint.- Parameters:
n- number of instances
-
reportReference
public void reportReference()Report a reference and increment the number of references of this memory footprint. -
reportReferences
public void reportReferences(int n) Report a reference and increment the number of references of this memory footprint.- Parameters:
n- number of references
-
reportEntry
public void reportEntry()Report an entry and increment the number of entries of this memory footprint. -
reportBytes
public void reportBytes(long payload) Report bytes on this memory footprint.- Parameters:
payload- the bytecount of the paylod
-
getBytecount
public long getBytecount()Calculate on the fly the bytecount associated with the reported instances.- Returns:
- the current bytecount
-