JeremyLiao / LiveEventBus

:mailbox_with_mail:EventBus for Android,消息总线,基于LiveData,具有生命周期感知能力,支持Sticky,支持AndroidX,支持跨进程,支持跨APP
Apache License 2.0
3.87k stars 529 forks source link

经常出现内存泄漏 #115

Open budaowengd opened 4 years ago

budaowengd commented 4 years ago

image

JeremyLiao commented 4 years ago

Forever模式订阅消息,需要调用removeObserver取消订阅 void observeForever(@NonNull Observer observer)

budaowengd commented 4 years ago

我没有使用observeForever进行注册, 是通过obserer 传入 fragment 进行注册的, 会经常出现内存泄漏

DarkHorsePXF commented 3 years ago

@luoxiong94 老铁,最终查到是因为这个obserer内存泄露吗?通常LiveData传Fragment自己的LifecycleOwner应该会自动解绑才对,我们正打算引用这个,看到了你说的这个坑。。。

hgncxzy commented 3 years ago

我最近也遇到了内存泄漏,目前在查找原因

ghost commented 3 years ago

@ #115 我遇到了类似的问题,不过不是因为框架问题,因为我用了navigation原因, fragment创建了两次,导致有一个observer没有被destroy正常释放,参考: https://stackoverflow.com/questions/64414301/why-onviewcreated-is-called-twice-in-android-app-using-navigation-components