Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Total retain size is negative #2700

Open
zienn opened this issue Aug 10, 2024 · 0 comments
Open

Total retain size is negative #2700

zienn opened this issue Aug 10, 2024 · 0 comments

Comments

@zienn
Copy link

zienn commented Aug 10, 2024

Description

Use ObjectDominators().buildDominatorTree(graph, ignoredRefs) analyze a hprof file to find large object in it. The total retain size is negative, and a lot of objects with a retain size morn than 2MB. This analyze cost all most 500s.

2024-08-10 11:30:45 [DEBUG] Total retained: -1636186211 bytes in 2027354 objects. Root dominators: 154364


2024-08-10 11:30:45 [DEBUG] class android.content.Intent #37425 Retained: 647898632 bytes (2992 self) 246 objects
├─java.lang.String #1584699 Retained: 2644472 bytes

2024-08-10 11:30:45 [DEBUG] class java.lang.Character$UnicodeBlock #38890 Retained: 552699958 bytes (1950 self) 421 objects
├─java.lang.Character$UnicodeBlock #1687945 Retained: 2644484 bytes (12 self) 2 objects
| ╰─java.lang.String #1567201 Retained: 2644472 bytes

2024-08-10 11:30:45 [DEBUG] java.security.Provider$Service #1723297 Retained: 60826466 bytes (52 self) 49 objects
├─java.util.ArrayList #1723299 Retained: 55537470 bytes (20 self) 46 objects
| ╰─java.lang.Object[] #2438100 Retained: 55537450 bytes (240 self) 45 objects
|   ├─java.lang.String #1725818 Retained: 2644472 bytes

Steps to Reproduce

  1. dump a hprof file from android device
  2. buildDominatorTree like below
heapDumpFile.openHeapGraph(proguardMapping = proguardMapping).use { graph ->
            val weakAndFinalizerRefs = EnumSet.of(REFERENCES, FINALIZER_WATCHDOG_DAEMON)
            val ignoredRefs = ReferenceMatcher.fromListBuilders(weakAndFinalizerRefs).map { matcher ->
                matcher as IgnoredReferenceMatcher
            }
            val dominatorTree = ObjectDominators().buildDominatorTree(graph, ignoredRefs)

            val root = dominatorTree.getValue(ValueHolder.NULL_REFERENCE)
            val summary =
                "Total retained: ${root.retainedSize} bytes in ${root.retainedCount} objects. Root dominators: ${root.dominatedObjectIds.size}\n\n"
...
  1. Look at the log output

Version Information

  • LeakCanary version: 3.0-alpha-8
  • Android OS version: 5.1
  • Gradle version:8.5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant