mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
GCWatcher: more diagnostics
This commit is contained in:
@@ -32,7 +32,7 @@ public class GCUtil {
|
||||
* In tests, if you can exactly point to objects you want to GC, use {@code GCWatcher.tracking(objects).tryGc()}
|
||||
* which is faster and has more chances to succeed.
|
||||
* <p></p>
|
||||
* Commits / hours of tweaking method code: 7 / 6
|
||||
* Commits / hours of tweaking method code: 10 / 6
|
||||
*/
|
||||
@TestOnly
|
||||
public static void tryGcSoftlyReachableObjects() {
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
package com.intellij.util.ref;
|
||||
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.reference.SoftReference;
|
||||
import com.intellij.util.MemoryDumpHelper;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
@@ -73,6 +74,9 @@ public class GCWatcher {
|
||||
*/
|
||||
public void tryGc() {
|
||||
if (!GCUtil.allocateTonsOfMemory(this::isEverythingCollected)) {
|
||||
String message = "Couldn't garbage-collect some objects, they might still be reachable from GC roots: " +
|
||||
ContainerUtil.mapNotNull(myReferences, SoftReference::dereference);
|
||||
|
||||
try {
|
||||
File file = new File(System.getProperty("teamcity.build.tempDir", System.getProperty("java.io.tmpdir")), "GCWatcher.hprof.zip");
|
||||
MemoryDumpHelper.captureMemoryDumpZipped(file);
|
||||
@@ -83,7 +87,7 @@ public class GCWatcher {
|
||||
catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
throw new IllegalStateException("Couldn't garbage-collect all passed objects, they might still be reachable from GC roots");
|
||||
throw new IllegalStateException(message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user