Module com.s8.api

Class MemoryFootprint

java.lang.Object
com.s8.api.bytes.MemoryFootprint

public class MemoryFootprint extends Object
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

    Fields
    Modifier and Type
    Field
    Description
    static final long
    Bytecount default for map entry
    static final long
    Proxy of object allocation in RAM: object.
    static final long
    Bytecount default for object reference
  • Constructor Summary

    Constructors
    Constructor
    Description
    Default constructor
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    Calculate on the fly the bytecount associated with the reported instances.
    void
    reportBytes(long payload)
    Report bytes on this memory footprint.
    void
    Report an entry and increment the number of entries of this memory footprint.
    void
    Report an instance and increment the number of instance of this memory footprint.
    void
    Report many instances and increment the number of instance of this memory footprint.
    void
    Report a reference and increment the number of references of this memory footprint.
    void
    Report a reference and increment the number of references of this memory footprint.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • OBJECT_ALLOCATION_BYTECOUNT

      public static final long OBJECT_ALLOCATION_BYTECOUNT

      Proxy 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_BYTECOUNT
      Bytecount default for object reference
      See Also:
    • ENTRY_BYTECOUNT

      public static final long ENTRY_BYTECOUNT
      Bytecount 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