am 7ac5a9ac: am 4bc5909a: Merge "Fix issue #11050678: Large memory leak in ActivityStack" into klp-dev
* commit '7ac5a9acb8c110620eac04db1eabecbbf64c0744':
Fix issue #11050678: Large memory leak in ActivityStack
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index c81f785..ba79ce3 100644
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -3193,6 +3193,7 @@
if (task.userId == tr.userId
&& ((task.affinity != null && task.affinity.equals(tr.affinity))
|| (task.intent != null && task.intent.filterEquals(tr.intent)))) {
+ tr.disposeThumbnail();
mRecentTasks.remove(i);
i--;
N--;
@@ -3204,7 +3205,7 @@
}
}
if (N >= MAX_RECENT_TASKS) {
- mRecentTasks.remove(N-1);
+ mRecentTasks.remove(N-1).disposeThumbnail();
}
mRecentTasks.add(0, task);
}
@@ -6738,6 +6739,7 @@
}
private void cleanUpRemovedTaskLocked(TaskRecord tr, int flags) {
+ tr.disposeThumbnail();
mRecentTasks.remove(tr);
mStackSupervisor.removeTask(tr);
final boolean killProcesses = (flags&ActivityManager.REMOVE_TASK_KILL_PROCESS) != 0;
diff --git a/services/java/com/android/server/am/TaskRecord.java b/services/java/com/android/server/am/TaskRecord.java
index 385253e..3d568ff 100644
--- a/services/java/com/android/server/am/TaskRecord.java
+++ b/services/java/com/android/server/am/TaskRecord.java
@@ -128,6 +128,16 @@
}
}
+ void disposeThumbnail() {
+ super.disposeThumbnail();
+ for (int i=mActivities.size()-1; i>=0; i--) {
+ ThumbnailHolder thumb = mActivities.get(i).thumbHolder;
+ if (thumb != this) {
+ thumb.disposeThumbnail();
+ }
+ }
+ }
+
ActivityRecord getTopActivity() {
for (int i = mActivities.size() - 1; i >= 0; --i) {
final ActivityRecord r = mActivities.get(i);
diff --git a/services/java/com/android/server/am/ThumbnailHolder.java b/services/java/com/android/server/am/ThumbnailHolder.java
index 02f4fcb..a6974f5 100644
--- a/services/java/com/android/server/am/ThumbnailHolder.java
+++ b/services/java/com/android/server/am/ThumbnailHolder.java
@@ -21,4 +21,9 @@
public class ThumbnailHolder {
Bitmap lastThumbnail; // Last thumbnail captured for this item.
CharSequence lastDescription; // Last description captured for this item.
+
+ void disposeThumbnail() {
+ lastThumbnail = null;
+ lastDescription = null;
+ }
}