diff --git a/platform/core-impl/src/com/intellij/psi/impl/smartPointers/SmartPointerManagerImpl.java b/platform/core-impl/src/com/intellij/psi/impl/smartPointers/SmartPointerManagerImpl.java index 28a99999203e..6546eee15399 100644 --- a/platform/core-impl/src/com/intellij/psi/impl/smartPointers/SmartPointerManagerImpl.java +++ b/platform/core-impl/src/com/intellij/psi/impl/smartPointers/SmartPointerManagerImpl.java @@ -44,12 +44,6 @@ import java.util.*; public class SmartPointerManagerImpl extends SmartPointerManager { private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.smartPointers.SmartPointerManagerImpl"); private static final ReferenceQueue ourQueue = new ReferenceQueue(); - @SuppressWarnings("unused") private static final LowMemoryWatcher ourWatcher = LowMemoryWatcher.register(new Runnable() { - @Override - public void run() { - processQueue(); - } - }); private final Project myProject; private final Key POINTERS_KEY; @@ -61,6 +55,15 @@ public class SmartPointerManagerImpl extends SmartPointerManager { POINTERS_KEY = Key.create("SMART_POINTERS for "+project); } + static { + LowMemoryWatcher.register(new Runnable() { + @Override + public void run() { + processQueue(); + } + }, ApplicationManager.getApplication()); + } + private static void processQueue() { while (true) { PointerReference reference = (PointerReference)ourQueue.poll(); diff --git a/platform/core-impl/src/com/intellij/psi/impl/source/AstPathPsiMap.java b/platform/core-impl/src/com/intellij/psi/impl/source/AstPathPsiMap.java index 539a68f5672d..d1368f93a795 100644 --- a/platform/core-impl/src/com/intellij/psi/impl/source/AstPathPsiMap.java +++ b/platform/core-impl/src/com/intellij/psi/impl/source/AstPathPsiMap.java @@ -49,7 +49,7 @@ class AstPathPsiMap { AstPathPsiMap(@NotNull Project project) { MyReferenceQueue queue = project.getUserData(STUB_PSI_REFS); - myQueue = queue != null ? queue : ((UserDataHolderEx)project).putUserDataIfAbsent(STUB_PSI_REFS, new MyReferenceQueue()); + myQueue = queue != null ? queue : ((UserDataHolderEx)project).putUserDataIfAbsent(STUB_PSI_REFS, new MyReferenceQueue(project)); } void invalidatePsi() { @@ -100,12 +100,14 @@ class AstPathPsiMap { } private static class MyReferenceQueue extends ReferenceQueue> { - @SuppressWarnings("unused") LowMemoryWatcher watcher = LowMemoryWatcher.register(new Runnable() { - @Override - public void run() { - cleanupStaleReferences(); - } - }); + MyReferenceQueue(Project project) { + LowMemoryWatcher.register(new Runnable() { + @Override + public void run() { + cleanupStaleReferences(); + } + },project); + } void cleanupStaleReferences() { while (true) { diff --git a/platform/util/src/com/intellij/util/io/CompressedAppendableFile.java b/platform/util/src/com/intellij/util/io/CompressedAppendableFile.java index cb805c134b15..5dd735458341 100644 --- a/platform/util/src/com/intellij/util/io/CompressedAppendableFile.java +++ b/platform/util/src/com/intellij/util/io/CompressedAppendableFile.java @@ -56,7 +56,7 @@ public class CompressedAppendableFile { private static final int myMinAppendBufferLength = 1024; public static final String INCOMPLETE_CHUNK_LENGTH_FILE_EXTENSION = ".s"; - @SuppressWarnings("unused") private final LowMemoryWatcher myLowMemoryWatcher; + private final LowMemoryWatcher myLowMemoryWatcher; public CompressedAppendableFile(File file) { this(file, PersistentBTreeEnumerator.PAGE_SIZE); @@ -434,6 +434,7 @@ public class CompressedAppendableFile { } public synchronized void dispose() { + myLowMemoryWatcher.stop(); force(); }