0

InstagramActivity is First Activity which will visible to user after splashscreen. GetDataFromServer is a singleton which i use for network call using retrofit.

I couldn't understand mLoadedApk and mReceivers mentioned in the leakcanary logs. As there is no reference variable I have declared in my code.

D/LeakCanary: ​
====================================
HEAP ANALYSIS RESULT
====================================
1 APPLICATION LEAKS

References underlined with "~~~" are likely causes.
Learn more at https://squ.re/leaks.

968964 bytes retained by leaking objects
Signature: a29bf580df87c6f6ad305a8d9f7b3bc3a01ea992
┬───
│ GC Root: System class
│
├─ android.provider.FontsContract class
│    Leaking: NO (GetDataFromServer↓ is not leaking and a class is never leaking)
│    ↓ static FontsContract.sContext
├─ instant.saver.for_instagram.api.GetDataFromServer instance
│    Leaking: NO (Application is a singleton)
│    mBase instance of android.app.ContextImpl
│    ↓ Application.mLoadedApk
│                  ~~~~~~~~~~
├─ android.app.LoadedApk instance
│    Leaking: UNKNOWN
│    Retaining 1.8 kB in 31 objects
│    mApplication instance of instant.saver.for_instagram.api.GetDataFromServer
│    Receivers
│    ..InstagramActivity@316939088
│    ....InstagramActivity$2@322490448
│    ..GetDataFromServer@316729128
│    ....VisibilityTracker@322489032
│    ↓ LoadedApk.mReceivers
│                ~~~~~~~~~~
├─ android.util.ArrayMap instance
│    Leaking: UNKNOWN
│    Retaining 1.3 kB in 18 objects
│    ↓ ArrayMap.mArray
│               ~~~~~~
├─ java.lang.Object[] array
│    Leaking: UNKNOWN
│    Retaining 1.3 kB in 16 objects
│    ↓ Object[].[0]
│               ~~~
╰→ instant.saver.for_instagram.InstagramActivity instance
​     Leaking: YES (ObjectWatcher was watching this because instant.saver.for_instagram.InstagramActivity received
​     Activity#onDestroy() callback and Activity#mDestroyed is true)
​     Retaining 969.0 kB in 17175 objects
​     key = 20591e0c-1b12-4810-bc0c-50d74a008298
​     watchDurationMillis = 14793
​     retainedDurationMillis = 9769
​     mApplication instance of instant.saver.for_instagram.api.GetDataFromServer
​     mBase instance of androidx.appcompat.view.ContextThemeWrapper
====================================
0 LIBRARY LEAKS

A Library Leak is a leak caused by a known bug in 3rd party code that you do not have control over.
See https://square.github.io/leakcanary/fundamentals-how-leakcanary-works/#4-categorizing-leaks
====================================
0 UNREACHABLE OBJECTS

An unreachable object is still in memory but LeakCanary could not find a strong reference path
from GC roots.
====================================
METADATA

Please include this in bug reports and Stack Overflow questions.

Build.VERSION.SDK_INT: 30
Build.MANUFACTURER: OnePlus
LeakCanary version: 2.7
App process name: instant.saver.for_instagram
Stats: LruCache[maxSize=3000,hits=3479,misses=88288,hitRate=3%]
RandomAccess[bytes=4242256,reads=88288,travel=46629354274,range=25009860,size=31821126]
Heap dump reason: 4 retained objects, app is not visible
Analysis duration: 5231 ms
Heap dump file path: /storage/emulated/0/Download/leakcanary-instant.saver.for_instagram/2021-11-10_11-02-28_887.hprof
Heap dump timestamp: 1636522400108
Heap dump duration: 45952 ms
====================================[enter image description here][1]
  • Please share the code snippets to understand this better way – Raj Suvariya Nov 10 '21 at 09:00
  • Please provide enough code so others can better understand or reproduce the problem. – Community Nov 11 '21 at 03:31
  • Thanks Here is the solution. mLoadedApk is linked with Boradcast receiver which needs to be deregistered before destroying activity/view. Which i didn't do previously. https://stackoverflow.com/questions/66611127/leakcanary-not-giving-enough-information-to-identify-leak – Roshan Kumar Nayak. Nov 11 '21 at 07:47

0 Answers0