Skip to content

Fix activity leak. #1066

Open
wants to merge 1 commit into from

1 participant

@kurganec

The leak is found in HomeView.mIconView.mCallback.mContext

Turns out when we call in ActionBarView:212

 mIcon = pm.getActivityIcon(((Activity) context).getComponentName());                                             

the system returns the same Icon,

So the ImageView from second started activity sets its callback and it prevents the activity to be garbage collected
The leak is reproducible in 2.3.6

On the later versions of sdk type of Drawable.mCallback changed from Callback to WeakReference so it cant be reproduced on newer sdk versions

Steps to reproduce:

1. start activity1

2. start activity2

3. finish activity2

4. activity2 will remain in memory

There is a demonstration of the leak https://github.com/kurganec/ActionBarSherlock/tree/activity_leak in known_bugs project

@kurganec kurganec Fix activity leak.
Make a copy of application/activity icon, so we do not leak activity on devices with old sdk version
d0773dc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.