leakcanary icon indicating copy to clipboard operation
leakcanary copied to clipboard

250+ MB Memory Usage by Shark package

Open sahil2441 opened this issue 2 years ago • 4 comments

Description

My app has leakcanary enabled and it crashed due to memory pressure. I pulled a heap dump and noticed that shark had a total of 250MB+ in retained size.

Is shark expected to hold this much amount of memory ?

Screenshot from 2022-09-08 10-09-10

Version Information

  • LeakCanary version: 2.9.1
  • Android OS version: Pixel 6; Android 13
  • Gradle version: 7.1.1

sahil2441 avatar Sep 08 '22 17:09 sahil2441

Are you sure this is a sum, rather than being sub parts? Android Studio memory analyze tends to not be great at this.

If you could download that heap dump and share it here, I can take a look.

Also would be helpful to have the heapdump that was being analyzed.

250Mb is definitely a lot, Shark is designed to work with very little memory.. in principle!

pyricau avatar Sep 13 '22 20:09 pyricau

Sure @pyricau. I shared the heap dump with you. Let me know if you didn't receive it.

sahil2441 avatar Sep 21 '22 17:09 sahil2441

Thanks!

  • The heap dump file is 187Mb
  • Profiler shows memory jumping by 150Mb as part of the analysis.
  • Heap dump shows retained size of 108Mb with 89% (85Mb) strongly reachable.
  • 65Mb for the in memory index, 17Mb for the dominator tree
  • 20Mb of instance index
  • the hprof string cache is 18Mb, has 200K entries for a 500K size. Keys is 4Mb
  • 16Mb worth of class data

So that large but I guess not totally unexpected?

I couldn't repro "250Mb retained", so I'd love a heap dump of that moment in time. You can export that from Android Studio by clicking on the floppy drive icon.

pyricau avatar Nov 11 '22 00:11 pyricau

Actually I think I'm mistaken you already sent me that, rather than the heap dump that was being analyzed itself?

pyricau avatar Nov 11 '22 00:11 pyricau