public class StandardMemoryStrategy extends MemoryStrategy
Modifier and Type | Field and Description |
---|---|
private long[] |
gcs |
private int |
gcs_pos |
private long |
prevTreshold |
private boolean |
proper |
private long |
properByte |
private int |
tresholdCount |
error, lastGC, log, name
Constructor and Description |
---|
StandardMemoryStrategy() |
Modifier and Type | Method and Description |
---|---|
protected long |
available()
memory that is available including increasing total memory up to maximum
|
private void |
checkProper(long available) |
protected 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 long |
getAverageGCFree()
This method calculates the average amount of bytes freed by the last GCs forced by this class
|
protected long |
maxMemory()
maximum memory the Java virtual will allocate machine; may vary over time in some cases
|
protected boolean |
properState() |
protected boolean |
request(long size,
boolean force,
java.util.concurrent.atomic.AtomicBoolean shortStatus)
Tries to free a specified amount of bytes.
|
private boolean |
request0(long size,
boolean force) |
protected void |
resetProperState()
forced enable properState - StandardMemoryStrategy only
|
protected void |
setProperMbyte(long mbyte)
set the memory to be available
|
protected long |
total()
currently allocated memory in the Java virtual machine; may vary over time
|
protected long |
used()
memory that is currently bound in objects
|
getName, hasError
private final long[] gcs
private int gcs_pos
private long properByte
private long prevTreshold
private int tresholdCount
private boolean proper
protected final boolean gc(int last, java.lang.String info)
gc
in class MemoryStrategy
last
- time which must be passed since lased gcinfo
- additional info for logprotected final long getAverageGCFree()
0
if no
GC has been run yetprotected final long free()
free
in class MemoryStrategy
protected final long available()
available
in class MemoryStrategy
protected final long maxMemory()
maxMemory
in class MemoryStrategy
protected final long total()
total
in class MemoryStrategy
protected 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
request
in class MemoryStrategy
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 memoryprivate boolean request0(long size, boolean force)
protected final long used()
used
in class MemoryStrategy
protected boolean properState()
properState
in class MemoryStrategy
protected void resetProperState()
MemoryStrategy
resetProperState
in class MemoryStrategy
protected void setProperMbyte(long mbyte)
setProperMbyte
in class MemoryStrategy
private void checkProper(long available)