Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

respect non-reserved Memory in GenerationMemoryStrategy and enable it again

sixcoolerc9aaa9e00aa2
diff --git a/source/net/yacy/kelondro/util/GenerationMemoryStrategy.java b/source/net/yacy/kelondro/util/GenerationMemoryStrategy.java
index 20d47daa8..2177ae2c8 100644
--- a/source/net/yacy/kelondro/util/GenerationMemoryStrategy.java
+++ b/source/net/yacy/kelondro/util/GenerationMemoryStrategy.java
@@ -93,6 +93,14 @@ public class GenerationMemoryStrategy extends MemoryStrategy {
protected final long maxMemory() {
return heap.getHeapMemoryUsage().getMax();
}
+
+ /**
+ * currently not reserved memory
+ * @return bytes
+ */
+ private final long unreserved() {
+ return Math.max(0, maxMemory() - total());
+ }
/**
* checks if a specified amount of bytes are available
@@ -124,7 +132,7 @@ public class GenerationMemoryStrategy extends MemoryStrategy {
*/
private final long oldAvailable() {
final MemoryUsage usage = getUsage(old, true);
- return usage.getCommitted() - usage.getUsed();
+ return unreserved() + usage.getCommitted() - usage.getUsed();
}
/**
diff --git a/source/net/yacy/kelondro/util/MemoryControl.java b/source/net/yacy/kelondro/util/MemoryControl.java
index 0866f76ac..237c76ddf 100644
--- a/source/net/yacy/kelondro/util/MemoryControl.java
+++ b/source/net/yacy/kelondro/util/MemoryControl.java
@@ -37,6 +37,9 @@ public class MemoryControl {
if (strategy == null || strategy.hasError()) {
if (!usingStandardStrategy) {
strategy = new GenerationMemoryStrategy();
+// if (strategy.hasError()) { // perhaps we do have a G1
+// strategy = new G1MemoryStrategy();
+// }
// fall back if error detected
if (strategy.hasError()) {
usingStandardStrategy = true;
@@ -50,12 +53,10 @@ public class MemoryControl {
}
public final static void setStandardStrategy(final boolean std) {
- /*
- if (usingStandardStrategy != std) {
+ if (usingStandardStrategy != std) {
usingStandardStrategy = std;
strategy = null;
}
- */
}
/**