Package org.opends.server.core
Class MemoryQuota
- java.lang.Object
-
- org.opends.server.core.MemoryQuota
-
public final 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 MemoryQuota()Returns the memory quota reservation system for this server instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanacquireMemory(long size)Reserves the requested amount of memory in OldGen.longgetAvailableMemory()Returns how much memory is currently not reserved (free) in OldGen.longgetMaxMemory()Returns the maximum amount of memory the server will use when giving quotas.booleanisMemoryAvailable(long size)Check enough memory is available in the reservable pool.intmemBytesToPercent(long size)Translates bytes to percent of reservable memory.longmemPercentToBytes(int percent)Translates a percentage of memory to the equivalent number of bytes.voidreleaseMemory(long size)Declares OldGen memory is not needed anymore.
-
-
-
Method Detail
-
getMaxMemory
public long getMaxMemory()
Returns the maximum amount of memory the server will use when giving quotas.- Returns:
- the maximum amount of memory the server will use when giving quotas
-
isMemoryAvailable
public boolean isMemoryAvailable(long size)
Check enough memory is available in the reservable pool.- Parameters:
size- the amount of requested memory- Returns:
- true if enough memory is available in the reservable pool
-
acquireMemory
public boolean acquireMemory(long size)
Reserves the requested amount of memory in OldGen.- Parameters:
size- 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.- Returns:
- how much memory is currently not reserved (free) in OldGen
-
memBytesToPercent
public int memBytesToPercent(long size)
Translates bytes to percent of reservable memory.- Parameters:
size- the amount of memory in bytes- Returns:
- percent of reservable memory
-
memPercentToBytes
public long memPercentToBytes(int percent)
Translates a percentage of memory to the equivalent number of bytes.- Parameters:
percent- a percentage of memory- Returns:
- the equivalent number of bytes
-
releaseMemory
public void releaseMemory(long size)
Declares OldGen memory is not needed anymore.- Parameters:
size- the amount of memory to return
-
-