Class MemoryQuota

java.lang.Object
org.opends.server.core.MemoryQuota

public class MemoryQuota extends Object
Estimates the amount of memory in the running JVM for use of long term caches by looking at the Old Generation, where implemented, or at the Runtime information as fallback. Allows for reserving memory to avoid over commitment. There is a fudge factor involved, so it is not byte exact.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Returns the memory quota reservation system for this server instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    acquireMemory(long sizeInBytes)
    Reserves the requested amount of memory in OldGen.
    long
    Returns how much memory is currently not reserved (free) in OldGen (in bytes).
    long
    Returns the amount of reservable memory in bytes.
    boolean
    isMemoryAvailable(long sizeInBytes)
    Check enough memory is available in the reservable pool.
    int
    memBytesToPercent(long sizeInBytes)
    Translates bytes to percent of reservable memory.
    long
    memPercentToBytes(int percent)
    Translates a percentage of reservable memory to the equivalent number of bytes.
    void
    releaseMemory(long sizeInBytes)
    Declares OldGen memory is not needed anymore.
    boolean
    resizeAcquiredMemory(long previouslyAcquiredSizeInBytes, long newlyAcquiredSizeInBytes)
    Resizes a previously requested amount of memory in OldGen.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • MemoryQuota

      public MemoryQuota()
      Returns the memory quota reservation system for this server instance.
  • Method Details

    • getReservableMemory

      public long getReservableMemory()
      Returns the amount of reservable memory in bytes.
      Returns:
      The amount of reservable memory in bytes.
    • isMemoryAvailable

      public boolean isMemoryAvailable(long sizeInBytes)
      Check enough memory is available in the reservable pool.
      Parameters:
      sizeInBytes - the amount of requested memory (in bytes)
      Returns:
      true if enough memory is available in the reservable pool
    • resizeAcquiredMemory

      public boolean resizeAcquiredMemory(long previouslyAcquiredSizeInBytes, long newlyAcquiredSizeInBytes)
      Resizes a previously requested amount of memory in OldGen.
      Parameters:
      previouslyAcquiredSizeInBytes - the previously requested amount of memory (in bytes)
      newlyAcquiredSizeInBytes - the new requested amount of memory (in bytes)
      Returns:
      true if the new requested amount of memory in OldGen could be reserved
    • acquireMemory

      public boolean acquireMemory(long sizeInBytes)
      Reserves the requested amount of memory in OldGen.
      Parameters:
      sizeInBytes - the requested amount of memory (in bytes)
      Returns:
      true if the requested amount of memory in OldGen could be reserved
    • getAvailableMemory

      public long getAvailableMemory()
      Returns how much memory is currently not reserved (free) in OldGen (in bytes).
      Returns:
      how much memory is currently not reserved (free) in OldGen (in bytes)
    • memBytesToPercent

      public int memBytesToPercent(long sizeInBytes)
      Translates bytes to percent of reservable memory.
      Parameters:
      sizeInBytes - the amount of memory (in bytes)
      Returns:
      percent of reservable memory
    • memPercentToBytes

      public long memPercentToBytes(int percent)
      Translates a percentage of reservable memory to the equivalent number of bytes.
      Parameters:
      percent - a percentage of reservable memory
      Returns:
      the equivalent number of bytes
    • releaseMemory

      public void releaseMemory(long sizeInBytes)
      Declares OldGen memory is not needed anymore.
      Parameters:
      sizeInBytes - the amount of memory to return (in bytes)