speedup: call force() only at the end of the build, between chunk builds drop only...
[idea/community.git] / platform / util / src / com / intellij / util / io / PersistentHashMap.java
index 5e5aba43cd67889501caed6f5d6f4b54e46a816e..297b733d754192a9288cc81abd3cd9620f1657b3 100644 (file)
@@ -124,14 +124,10 @@ public class PersistentHashMap<Key, Value> extends PersistentEnumeratorDelegate<
   private final LowMemoryWatcher myAppendCacheFlusher = LowMemoryWatcher.register(new LowMemoryWatcher.ForceableAdapter() {
     public void force() {
       //System.out.println("Flushing caches: " + myFile.getPath());
-      synchronized (myEnumerator) {
-        synchronized (PersistentEnumerator.ourLock) {
-          clearAppenderCaches();
-        }
-      }
+      dropMemoryCaches();
     }
   });
-  
+
   public PersistentHashMap(final File file, KeyDescriptor<Key> keyDescriptor, DataExternalizer<Value> valueExternalizer) throws IOException {
     this(file, keyDescriptor, valueExternalizer, INITIAL_INDEX_SIZE);
   }
@@ -195,6 +191,14 @@ public class PersistentHashMap<Key, Value> extends PersistentEnumeratorDelegate<
     }
   }
 
+  public void dropMemoryCaches() {
+    synchronized (myEnumerator) {
+      synchronized (PersistentEnumerator.ourLock) {
+        clearAppenderCaches();
+      }
+    }
+  }
+
   public int getGarbageSize() {
     return (int)myLiveAndGarbageKeysCounter;
   }