square / leakcanary

A memory leak detection library for Android.
https://square.github.io/leakcanary
Apache License 2.0
29.44k stars 3.97k forks source link

Sometimes too slow to build dominator tree #2725

Open zienn opened 3 days ago

zienn commented 3 days ago

Description

Build dominator tree cost too much time in some bad case

Steps to Reproduce

I can provide a hprof file, and build as below

heapDumpFile.openHeapGraph().use { graph ->
    val heapAnalyzer = HeapAnalyzer(OnAnalysisProgressListener.NO_OP)

    val weakAndFinalizerRefs = EnumSet.of(REFERENCES, FINALIZER_WATCHDOG_DAEMON)
    val ignoredRefs = ReferenceMatcher.fromListBuilders(weakAndFinalizerRefs).map { matcher ->
        matcher as IgnoredReferenceMatcher
    }

    val dominatorTree = ObjectDominators().buildDominatorTree(graph, ignoredRefs)
}

Expected behavior: [finish in few minutes]

In fact, it takes hundreds of minutes

Version Information

Additional Information

Any additional information, configuration or data that might be necessary to reproduce the issue.

zienn commented 3 days ago

Here is the hprof file download link