mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
clear java bean info cache every 100 tests
This commit is contained in:
@@ -94,7 +94,7 @@ import com.intellij.psi.impl.source.tree.injected.InjectedLanguageManagerImpl;
|
||||
import com.intellij.psi.templateLanguages.TemplateDataLanguageMappings;
|
||||
import com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.GCUtil;import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.LocalTimeCounter;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.indexing.FileBasedIndex;
|
||||
@@ -590,7 +590,15 @@ public abstract class LightPlatformTestCase extends UsefulTestCase implements Da
|
||||
checkEditorsReleased();
|
||||
}
|
||||
documentManager.clearUncommittedDocuments();
|
||||
|
||||
if (ourTestCount++ % 100 == 0) {
|
||||
// some tests are written in Groovy, and running all of them may result in some 40M of memory wasted on bean infos
|
||||
// so let's clear the cache every now and then to ensure it doesn't grow too large
|
||||
GCUtil.tryClearBeanInfoCache();
|
||||
}
|
||||
}
|
||||
|
||||
private static int ourTestCount = 0;
|
||||
|
||||
public static PsiDocumentManagerImpl clearUncommittedDocuments(@NotNull Project project) {
|
||||
PsiDocumentManagerImpl documentManager = (PsiDocumentManagerImpl)PsiDocumentManager.getInstance(project);
|
||||
|
||||
@@ -81,7 +81,12 @@ public class GCUtil {
|
||||
|
||||
private static final boolean ourHasBeanInfoCache = SystemInfo.isJavaVersionAtLeast("1.7");
|
||||
|
||||
private static void tryClearBeanInfoCache() {
|
||||
/**
|
||||
* Using java beans (e.g. Groovy does it) results in all referenced class infos being cached in ThreadGroupContext. A valid fix
|
||||
* would be to hold BeanInfo objects on soft references, but that should be done in JDK. So let's clear this cache manually for now,
|
||||
* in clients that are known to create bean infos.
|
||||
*/
|
||||
public static void tryClearBeanInfoCache() {
|
||||
if (ourHasBeanInfoCache) {
|
||||
try {
|
||||
Class<?> aClass = Class.forName("java.beans.ThreadGroupContext");
|
||||
|
||||
Reference in New Issue
Block a user