Skip to content

Commit

Permalink
Fix memory leak in Launcher
Browse files Browse the repository at this point in the history
Leak happened when a stack view was on the
workspace and then workspace forced a rebind of
its items (for example, when an app was installed)

Bug # 5629171
  • Loading branch information
mikejurka committed Dec 1, 2011
1 parent 3924df8 commit 05bf644
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/com/android/launcher2/Launcher.java
Expand Up @@ -2920,6 +2920,7 @@ public void startBinding() {
final CellLayout layoutParent = (CellLayout) workspace.getChildAt(i);
layoutParent.removeAllViewsInLayout();
}
mWidgetsToAdvance.clear();
if (mHotseat != null) {
mHotseat.resetLayout();
}
Expand Down
5 changes: 4 additions & 1 deletion src/com/android/launcher2/LauncherModel.java
Expand Up @@ -176,12 +176,16 @@ private ArrayList<ItemInfo> unbindWorkspaceItemsOnMainThread() {
// Ensure that we don't use the same workspace items data structure on the main thread
// by making a copy of workspace items first.
final ArrayList<ItemInfo> workspaceItems = new ArrayList<ItemInfo>(sWorkspaceItems);
final ArrayList<ItemInfo> appWidgets = new ArrayList<ItemInfo>(sAppWidgets);
mHandler.post(new Runnable() {
@Override
public void run() {
for (ItemInfo item : workspaceItems) {
item.unbind();
}
for (ItemInfo item : appWidgets) {
item.unbind();
}
}
});

Expand Down Expand Up @@ -1229,7 +1233,6 @@ public void run() {
}
});

// Unbind previously bound workspace items to prevent a leak of AppWidgetHostViews.
final ArrayList<ItemInfo> workspaceItems = unbindWorkspaceItemsOnMainThread();

// Add the items to the workspace.
Expand Down

0 comments on commit 05bf644

Please sign in to comment.