Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MVVM使用SnackbarMessageQueue导致不能被GC(内存泄露) #3554

Open
daigs opened this issue May 10, 2024 · 1 comment
Open

MVVM使用SnackbarMessageQueue导致不能被GC(内存泄露) #3554

daigs opened this issue May 10, 2024 · 1 comment
Labels
bug evaluation required Items is pending review or evaluation by the team

Comments

@daigs
Copy link

daigs commented May 10, 2024

Bug explanation

image
image
image
如上图,把SnackbarMessageQueue注入到TestGCViewModel,然后在TestGCView绑定,当关闭TestGCView时,不会触发TestGCView和TestGCViewModel的析构函数,即使手动GC,也不能触发

image
当我在TestGCView重写的OnClosed方法手动把Snackbar.MessageQueue=null释放引用后,就可以触发析构函数的执行

正常情况不是应该关闭view后,都会回收该view和对应的viewmodel的吗?

Version

5.0

@daigs daigs added bug evaluation required Items is pending review or evaluation by the team labels May 10, 2024
@daigs
Copy link
Author

daigs commented May 10, 2024

image
我改成不用依赖注入,直接new,就可以触发析构函数的执行

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug evaluation required Items is pending review or evaluation by the team
Projects
None yet
Development

No branches or pull requests

1 participant