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
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
protected final long available() {
return available(true);
return available(false);
}
/**
@ -70,7 +70,7 @@ public class GenerationMemoryStrategy extends MemoryStrategy {
* @return bytes
*/
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();
}
/**
@ -99,6 +99,14 @@ public class GenerationMemoryStrategy extends MemoryStrategy {
protected final long maxMemory() {
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
@ -151,7 +159,7 @@ public class GenerationMemoryStrategy extends MemoryStrategy {
* @return if survivor fits into old space
*/
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();
}

@ -162,7 +162,7 @@ public final class InstantBusyThread extends AbstractBusyThread implements BusyT
thread.setIdleSleep(-1);
thread.setBusySleep(-1);
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();
return thread;
}

Loading…
Cancel
Save