References underlined with "~~~" are likely causes.
Learn more at https://squ.re/leaks.
25806 bytes retained by leaking objects
Signature: 72cf858dfde339fc989df691ff8812b6a6a5e21
┬───
│ GC Root: Input or output parameters in native code
│
├─ okio.AsyncTimeout class
│ Leaking: NO (PathClassLoader↓ is not leaking and a class is never leaking)
│ ↓ static AsyncTimeout.$class$classLoader
├─ dalvik.system.PathClassLoader instance
│ Leaking: NO (XToast↓ is not leaking and A ClassLoader is never leaking)
│ ↓ ClassLoader.runtimeInternalObjects
├─ java.lang.Object[] array
│ Leaking: NO (XToast↓ is not leaking)
│ ↓ Object[].[2545]
├─ com.xuexiang.xui.widget.toast.XToast class
│ Leaking: NO (a class is never leaking)
│ ↓ static XToast.lastToast
│ ~~~~~
├─ android.widget.Toast instance
│ Leaking: UNKNOWN
│ Retaining 28.4 kB in 106 objects
│ mContext instance of com.yty.photolive.MyApp
│ ↓ Toast.mNextView
│ ~~~~~
╰→ android.widget.LinearLayout instance
Leaking: YES (ObjectWatcher was watching this because android.widget.
LinearLayout received View#onDetachedFromWindow() callback)
Retaining 25.8 kB in 92 objects
key = aeaaf857-d6d9-485c-9b2b-e1ef62493543
watchDurationMillis = 94540
retainedDurationMillis = 89540
View not part of a window view hierarchy
View.mAttachInfo is null (view detached)
View.mID = R.id.toast_root
View.mWindowAttachCount = 1
mContext instance of com.yty.photolive.MyApp
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: Xiaomi
LeakCanary version: 2.6
App process name: com.yty.photolive
Stats: LruCache[maxSize=3000,hits=5470,misses=79696,hitRate=6%]
RandomAccess[bytes=4197785,reads=79696,travel=41830516707,range=25481265,size=32
351626]
Heap dump reason: 1 retained objects, app is not visible
Analysis duration: 2952 ms
Heap dump file path: /storage/emulated/0/Download/leakcanary-com.yty.
photolive/2022-02-28_11-35-39_839.hprof
Heap dump timestamp: 1646019346941
Heap dump duration: 4094 ms
使用XUI的模板项目TemplateAppProject,使用XToastUtils,LeakCanary提示内存泄露:
1 APPLICATION LEAKS
References underlined with "~~~" are likely causes. Learn more at https://squ.re/leaks.
25806 bytes retained by leaking objects Signature: 72cf858dfde339fc989df691ff8812b6a6a5e21 ┬─── │ GC Root: Input or output parameters in native code │ ├─ okio.AsyncTimeout class │ Leaking: NO (PathClassLoader↓ is not leaking and a class is never leaking) │ ↓ static AsyncTimeout.$class$classLoader ├─ dalvik.system.PathClassLoader instance │ Leaking: NO (XToast↓ is not leaking and A ClassLoader is never leaking) │ ↓ ClassLoader.runtimeInternalObjects ├─ java.lang.Object[] array │ Leaking: NO (XToast↓ is not leaking) │ ↓ Object[].[2545] ├─ com.xuexiang.xui.widget.toast.XToast class │ Leaking: NO (a class is never leaking) │ ↓ static XToast.lastToast │
~~~~~ ├─ android.widget.Toast instance │ Leaking: UNKNOWN │ Retaining 28.4 kB in 106 objects │ mContext instance of com.yty.photolive.MyApp │ ↓ Toast.mNextView │~~~~~ ╰→ android.widget.LinearLayout instance Leaking: YES (ObjectWatcher was watching this because android.widget. LinearLayout received View#onDetachedFromWindow() callback) Retaining 25.8 kB in 92 objects key = aeaaf857-d6d9-485c-9b2b-e1ef62493543 watchDurationMillis = 94540 retainedDurationMillis = 89540 View not part of a window view hierarchy View.mAttachInfo is null (view detached) View.mID = R.id.toast_root View.mWindowAttachCount = 1 mContext instance of com.yty.photolive.MyApp0 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: Xiaomi LeakCanary version: 2.6 App process name: com.yty.photolive Stats: LruCache[maxSize=3000,hits=5470,misses=79696,hitRate=6%] RandomAccess[bytes=4197785,reads=79696,travel=41830516707,range=25481265,size=32 351626] Heap dump reason: 1 retained objects, app is not visible Analysis duration: 2952 ms Heap dump file path: /storage/emulated/0/Download/leakcanary-com.yty. photolive/2022-02-28_11-35-39_839.hprof Heap dump timestamp: 1646019346941 Heap dump duration: 4094 ms