simplification / speedup of GenerationMemoryStrategy

pull/27/head
sixcooler 9 years ago
parent f5a9948860
commit d3b9349b6f

@ -51,7 +51,7 @@ public class GenerationMemoryStrategy extends MemoryStrategy {
*/ */
@Override @Override
protected final long free() { protected final long free() {
return getUsage(eden, false).getCommitted() - getUsage(eden, false).getUsed(); return youngAvailable();
} }
/** /**
@ -61,7 +61,7 @@ public class GenerationMemoryStrategy extends MemoryStrategy {
*/ */
@Override @Override
protected final long available() { protected final long available() {
return available(true); return available(false);
} }
/** /**
@ -70,7 +70,7 @@ public class GenerationMemoryStrategy extends MemoryStrategy {
* @return bytes * @return bytes
*/ */
private final long available(final boolean force) { private final long available(final boolean force) {
return force & properState(force) ? Math.max(youngAvailable(), oldAvailable()) : Math.min(youngAvailable(), Math.max(M, oldAvailable())); return force & properState(force) ? Math.max(youngAvailable(), oldAvailable()) : oldAvailable();
} }
/** /**
@ -100,6 +100,14 @@ public class GenerationMemoryStrategy extends MemoryStrategy {
return heap.getHeapMemoryUsage().getMax(); return heap.getHeapMemoryUsage().getMax();
} }
/**
* get the memory that needs to be available for properState
*/
protected final long minMemory()
{
return getUsage(eden, true).getUsed();
}
/** /**
* checks if a specified amount of bytes are available * checks if a specified amount of bytes are available
* after the jvm recycled unused objects * after the jvm recycled unused objects
@ -151,7 +159,7 @@ public class GenerationMemoryStrategy extends MemoryStrategy {
* @return if survivor fits into old space * @return if survivor fits into old space
*/ */
private boolean properState(final boolean force) { private boolean properState(final boolean force) {
final long surv = force? Math.max(M, getUsage(survivor, false).getUsed()) : getUsage(survivor, false).getCommitted(); final long surv = force? M + getUsage(survivor, false).getUsed() : getUsage(survivor, false).getCommitted();
return surv < oldAvailable(); return surv < oldAvailable();
} }

@ -162,7 +162,7 @@ public final class InstantBusyThread extends AbstractBusyThread implements BusyT
thread.setIdleSleep(-1); thread.setIdleSleep(-1);
thread.setBusySleep(-1); thread.setBusySleep(-1);
thread.setMemPreReqisite(0); thread.setMemPreReqisite(0);
thread.setLoadPreReqisite(99); // this is called during initialization phase and some code parts depend on it; therefore we cannot set a prerequisite that prevents the start of that thread thread.setLoadPreReqisite(Double.MAX_VALUE); // this is called during initialization phase and some code parts depend on it; therefore we cannot set a prerequisite that prevents the start of that thread
thread.start(); thread.start();
return thread; return thread;
} }

Loading…
Cancel
Save