public abstract class MemoryStrategy
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected static boolean |
error |
protected static long |
lastGC |
protected static ConcurrentLog |
log |
protected static java.lang.String |
name |
Constructor and Description |
---|
MemoryStrategy() |
Modifier and Type | Method and Description |
---|---|
protected abstract long |
available()
memory that is available including increasing total memory up to maximum
|
protected abstract long |
free()
memory that is free without increasing of total memory taken from os
|
protected boolean |
gc(int last,
java.lang.String info)
Runs the garbage collector if last garbage collection is more than last millis ago
|
protected static java.lang.String |
getName() |
protected static boolean |
hasError() |
protected abstract long |
maxMemory()
maximum memory the Java virtual will allocate machine; may vary over time in some cases
|
protected abstract boolean |
properState() |
protected abstract boolean |
request(long size,
boolean force,
java.util.concurrent.atomic.AtomicBoolean shortStatus)
Tries to free a specified amount of bytes.
|
protected void |
resetProperState()
forced enable properState - StandardMemoryStrategy only
|
protected void |
setProperMbyte(long mbyte)
set the memory to be available for properState - StandardMemoryStrategy only
|
protected abstract long |
total()
currently allocated memory in the Java virtual machine; may vary over time
|
protected abstract long |
used()
memory that is currently bound in objects
|
protected static final ConcurrentLog log
protected static long lastGC
protected static boolean error
protected static java.lang.String name
protected static final boolean hasError()
protected static final java.lang.String getName()
protected boolean gc(int last, java.lang.String info)
last
- time which must be passed since lased gcinfo
- additional info for logprotected abstract long free()
protected abstract long available()
protected abstract long used()
protected abstract long total()
protected abstract long maxMemory()
protected abstract boolean request(long size, boolean force, java.util.concurrent.atomic.AtomicBoolean shortStatus)
Tries to free a specified amount of bytes.
If the currently available memory is enough, the method returns true
without
performing additional steps. If not, the behaviour depends on the parameter force
.
If false
, a Full GC is only performed if former GCs indicated that a GC should
provide enough free memory. If former GCs didn't but force
is set to true
a Full GC is performed nevertheless.
Setting the force
parameter to false doesn't necessarily mean, that no GC may be
performed by this method, if the currently available memory doesn't suffice!
Be careful with this method as GCs should always be the last measure to take
size
- the requested amount of free memory in bytesforce
- specifies whether a GC should be run even in case former GCs didn't provide enough memoryprotected abstract boolean properState()
protected void resetProperState()
protected void setProperMbyte(long mbyte)