make LeakHunter more stable: force garbage collection as we can. Should fix flaky testLeakHunterDoesntReportFalsePositivesFromWeakHashMap test

GitOrigin-RevId: bbbd9a6b5171b00dfc0a88e8c7e88d1fa9483f9b
This commit is contained in:
Dmitry Batkovich
2024-08-01 09:24:36 +02:00
committed by intellij-monorepo-bot
parent a8e464a998
commit 8e16b9aa6e

View File

@@ -20,6 +20,7 @@ import com.intellij.util.PairProcessor;
import com.intellij.util.ReflectionUtil;
import com.intellij.util.io.PersistentEnumeratorCache;
import com.intellij.util.ref.DebugReflectionUtil;
import com.intellij.util.ref.GCUtil;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -87,8 +88,7 @@ public final class LeakHunter {
}
PersistentEnumeratorCache.clearCacheForTests();
flushTelemetry();
//noinspection CallToSystemGC
System.gc();
GCUtil.tryGcSoftlyReachableObjects();
Runnable runnable = () -> {
try (AccessToken ignored = ProhibitAWTEvents.start("checking for leaks")) {
DebugReflectionUtil.walkObjects(10000, rootsSupplier.get(), suspectClass, __ -> true, (leaked, backLink) -> {