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

当一个MainActivity中包含一个ViewPager存在的问题 #9

Closed
burgessjp opened this issue Dec 6, 2016 · 2 comments
Closed

当一个MainActivity中包含一个ViewPager存在的问题 #9

burgessjp opened this issue Dec 6, 2016 · 2 comments
Labels

Comments

@burgessjp
Copy link
Owner

burgessjp commented Dec 6, 2016

当MainActivity(应用主界面,一般是和应用的生命周期是一样的)中包含一个ViewPager,ViewPager包含有很多的Fragment,当Fragment已经销毁的时候,然而其中的View还依然保存在SkinInflaterFactory的mSkinItems中,所以一直保存着其引用,不会释放,当Fragement重新创建的时候,又会有新的相同的View重新创建,由于MainActivity和应用的生命周期是一样的,mSkinItems一直不会被销毁,所以当多次滑动ViewPager就很容易发生内存溢出。目前正在寻求比较好的解决方案

@burgessjp burgessjp added the bug label Dec 6, 2016
@erichyx
Copy link

erichyx commented Dec 22, 2016

@burgessjp 建议你使用WeakReference 来保存那些View。

@burgessjp
Copy link
Owner Author

弱类型解决不了这个问题的,目前已经想到了解决方案,后面会有更新

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants