~/talk

Shark: Diving into the guts of LeakCanary's Hprof parser

Talkat droidcon NYC 2019 · 2019-08-26..08-27· [android]
slides:none on file

LeakCanary’s HPROF parser is rewritten as Shark in Kotlin and claims 10× less memory and 6× faster parsing; it replaces Perfetto’s heavy in-memory indexes with file-position pointers for instances, uses Okio and Java NIO to read on demand, and finds shortest root-to-object paths via breadth‑first search. A 160 MB heap that once forced 2 GB+ gets parsed in ~4s using ~250 MB, and switching HashMap indexes to a sorted byte-array map slashes index cost; profiling used YourKit to find dominant retainers.

AI-written summary · about

  1. 0:00Introduction to Shark
  2. 1:07What is Shark and LeakCanary 2
  3. 2:11How LeakCanary detects leaks
  4. 4:19Garbage collection basics
  5. 6:26Heap dumps and GC roots
  6. 9:36Heap parsing overview
  7. 13:02Out of memory with HPROF parser
  8. 17:36Analyzing heap parser memory usage
  9. 22:31Breadth-first search for leak paths
  10. 26:01HPROF file format and parsing
  11. 33:17Optimizing memory usage in Shark
  12. 41:45Key takeaways and conclusion
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.