ActionBarSherlock icon indicating copy to clipboard operation
ActionBarSherlock copied to clipboard

SherlockFragmentActivity seems to make my Activity leaks

Open guillaumeLeRoy opened this issue 12 years ago • 1 comments

Hi,

I created a small project to debug leaks on my application and it appears that SherlockActionBar version 4.3.1 may be responsible for the strange behaviours I encountered. If my Activity extends FragmentActivity, I can see that the system is calling onDestroy when it needs memory but if I use SherlockFragmentActivity the system never calls my Activity onDestroy method what finally causes an OutOfMemoryException. I used MAT to find some clues and it appears that sherlock keeps a weak reference of the my activity context, thus it should be ok.

I tested on many devices, connected to my computer or not and I always have the same problems. Are you aware of this problem and do you have a solution ?

You can find my test project on Github : https://github.com/guillaumeLeRoy/testLeak/

guillaumeLeRoy avatar Jul 22 '13 11:07 guillaumeLeRoy

I have the same problem on my HTC Desire (android 2.2). Look at my tiny activity https://gist.github.com/danikula/6384575#file-leakedactivity-java. It just starts itself and logs allocated native memory. I run this activity and tap on button for starting new activity. Every new activity extended from SherlockFragmentActivity consumes about 1.5MB! Log says: Allocated 5950808 bytes in native memory Allocated 7309864 bytes in native memory Allocated 8668864 bytes in native memory Allocated 10027840 bytes in native memory Allocated 11292576 bytes in native memory

I have no problem if I extend activity from SherlockActivity. Every new activity consumes 10 times less (0.15Mb): Allocated 4724600 bytes in native memory Allocated 4839096 bytes in native memory Allocated 5010320 bytes in native memory Allocated 5181608 bytes in native memory

Also I have no problem if use FragmentActivity from android-supoort library without ActionBarSherlock. This bug isn't reproduced on android 4.3

danikula avatar Aug 29 '13 23:08 danikula