Skip to content

Commit

Permalink
better memory protection during freemen cycle
Browse files Browse the repository at this point in the history
  • Loading branch information
orbiter committed Mar 10, 2007
1 parent 6faa262 commit 7a52b07
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions source/de/anomic/plasma/plasmaWordIndex.java
Expand Up @@ -53,6 +53,7 @@
import de.anomic.net.URL;
import de.anomic.plasma.urlPattern.plasmaURLPattern;
import de.anomic.server.logging.serverLog;
import de.anomic.server.serverMemory;
import de.anomic.yacy.yacyDHTAction;

public final class plasmaWordIndex implements indexRI {
Expand Down Expand Up @@ -139,15 +140,19 @@ public void setWordFlushSize(int flushsize) {
public void dhtOutFlushControl() {
// check for forced flush
synchronized (this) {
if ((dhtOutCache.getMaxWordCount() > wCacheMaxChunk ) || (dhtOutCache.size() > dhtOutCache.getMaxWordCount())) {
if ((dhtOutCache.getMaxWordCount() > wCacheMaxChunk ) ||
(dhtOutCache.size() > dhtOutCache.getMaxWordCount()) ||
(serverMemory.available() < collections.minMem())) {
flushCache(dhtOutCache, dhtOutCache.size() + flushsize - dhtOutCache.getMaxWordCount());
}
}
}
public void dhtInFlushControl() {
// check for forced flush
synchronized (this) {
if ((dhtInCache.getMaxWordCount() > wCacheMaxChunk ) || (dhtInCache.size() > dhtInCache.getMaxWordCount())) {
if ((dhtInCache.getMaxWordCount() > wCacheMaxChunk ) ||
(dhtInCache.size() > dhtInCache.getMaxWordCount())||
(serverMemory.available() < collections.minMem())) {
flushCache(dhtInCache, dhtInCache.size() + flushsize - dhtInCache.getMaxWordCount());
}
}
Expand Down Expand Up @@ -215,13 +220,15 @@ private void flushCache(indexRAMRI ram, int count) {
c = ram.getContainer(wordHash, null, -1);
if ((c != null) && (c.size() > wCacheMaxChunk)) {
containerList.add(ram.deleteContainer(wordHash));
if (serverMemory.available() < collections.minMem()) break; // protect memory during flush
} else {
collectMax = false;
}
}
count = count - containerList.size();
for (int i = 0; i < count; i++) { // possible position of outOfMemoryError ?
if (ram.size() == 0) break;
if (serverMemory.available() < collections.minMem()) break; // protect memory during flush
// select one word to flush
wordHash = ram.bestFlushWordHash();

Expand Down

0 comments on commit 7a52b07

Please sign in to comment.