sockeqwe / mosby

A Model-View-Presenter / Model-View-Intent library for modern Android apps
http://hannesdorfmann.com/mosby/
Apache License 2.0
5.49k stars 841 forks source link

Possible leak #198

Closed niltsiar closed 7 years ago

niltsiar commented 7 years ago

I've been playing a bit with the sample-mvi app and I've found that some views seem to be leaking. Dumping the heap after some orientation changes I can see multiple instances of ShoppingCartOverviewFragment, SelectCountToolbar, MainMenuLayout just to name some of the MVI views. Every instance of these classes except one have the mAttachInfo=null but the number of instances keeps increasing with each orientation change and it seems they are not being GC.

sockeqwe commented 7 years ago

While I can reproduce it (I see multiple instances of ShopplingCartOverViewFragment for example) in the heap dump, I think this is a false alarm. I might be wrong, but to me it seems that GC hasn't run yet. Therefore the "old" instances are still in the heap dump. If you run GC manually (and wait a few seconds) and then make a heap dump again you will see that there is only one instance remaining for each of them. Can you please verify/confirm the same behavior on your device/pc?

Also, Android studio's "leak detector" nor LeakCanary have reported a leak in the sample app.

niltsiar commented 7 years ago

You're right. I've tested it again and it's working properly. I've also tested it while debugging and instances are kept for ages while doing that so maybe that's what happened yesterday and I didn't realise that.

Sorry for the false alarm.

sockeqwe commented 7 years ago

No worries, thanks for reporting anyway!