FlutterToast
FlutterToast copied to clipboard
MethodCallHandlerImpl.mToast leaks toast
I'm filing this issue based on a leakcanary report found on Stack Overflow: https://stackoverflow.com/questions/66911405/toast-mnextview-and-framelayout-possible-leak-how-to-trace-the-cause
The key interesting part in the leaktrace is:
├─ io.flutter.embedding.engine.dart.DartMessenger instance
│ Leaking: UNKNOWN
│ Retaining 8.0 kB in 113 objects
│ ↓ DartMessenger.messageHandlers
│ ~~~~~~~~~~~~~~~
├─ java.util.HashMap instance
│ Leaking: UNKNOWN
│ Retaining 7.9 kB in 110 objects
│ ↓ HashMap.table
│ ~~~~~
├─ java.util.HashMap$Node[] array
│ Leaking: UNKNOWN
│ Retaining 7.8 kB in 109 objects
│ ↓ HashMap$Node[].[7]
│ ~~~
├─ java.util.HashMap$Node instance
│ Leaking: UNKNOWN
│ Retaining 6.8 kB in 67 objects
│ ↓ HashMap$Node.next
│ ~~~~
├─ java.util.HashMap$Node instance
│ Leaking: UNKNOWN
│ Retaining 6.8 kB in 65 objects
│ ↓ HashMap$Node.value
│ ~~~~~
├─ io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler instance
│ Leaking: UNKNOWN
│ Retaining 6.7 kB in 62 objects
│ ↓ MethodChannel$IncomingMethodCallHandler.handler
│ ~~~~~~~
├─ io.github.ponnamkarthik.toast.fluttertoast.MethodCallHandlerImpl instance
│ Leaking: UNKNOWN
│ Retaining 6.7 kB in 61 objects
│ context instance of com.example.app.Application
│ ↓ MethodCallHandlerImpl.mToast
│ ~~~~~~
├─ android.widget.Toast instance
│ Leaking: YES (This toast is done showing (Toast.mTN.mWM != null && Toast.
│ mTN.mView == null))
It shows that MethodCallHandlerImpl.mToast keeps a reference to the toast (and its view hierarchy) after it's done showing, and forever until a new toast is shown.
+1,显示完成后toast对象没有释放
+1 遇到此问题 toast对象没有释放 是否有解决的办法?