diff options
author | Adam Cohen <adamcohen@google.com> | 2014-10-31 11:48:25 -0700 |
---|---|---|
committer | Adam Cohen <adamcohen@google.com> | 2014-10-31 12:15:09 -0700 |
commit | 3f9c971e761222dc9fb4e5866f81c5f7a3348992 (patch) | |
tree | 02dcea77ed7b42fb5811011701e0d3f8859875b6 /src/com/android/launcher3/Launcher.java | |
parent | 5fd733dbaeff3f07fff98f24947b2e1ab89eff7d (diff) | |
download | android_packages_apps_Trebuchet-3f9c971e761222dc9fb4e5866f81c5f7a3348992.tar.gz android_packages_apps_Trebuchet-3f9c971e761222dc9fb4e5866f81c5f7a3348992.tar.bz2 android_packages_apps_Trebuchet-3f9c971e761222dc9fb4e5866f81c5f7a3348992.zip |
Adding a couple memory optimizations to Launcher
-> Always dispose of widget page views when leaving the activity.
These pages hold onto many bitmaps.
-> Clear database cache when leaving the activity.
Bug: 17967108
Change-Id: I10ebaaed14e7cd86f09a9afcabd73043705f21b8
Diffstat (limited to 'src/com/android/launcher3/Launcher.java')
-rw-r--r-- | src/com/android/launcher3/Launcher.java | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index bb7265e44..7fd8193bd 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -50,6 +50,7 @@ import android.content.pm.PackageManager.NameNotFoundException; import android.content.res.Configuration; import android.content.res.Resources; import android.database.ContentObserver; +import android.database.sqlite.SQLiteDatabase; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Color; @@ -3568,6 +3569,9 @@ public class Launcher extends Activity if (mSearchDropTargetBar != null) { mSearchDropTargetBar.hideSearchBar(false); } + + // This can hold unnecessary references to views. + mStateAnimation = null; } }); @@ -3853,6 +3857,9 @@ public class Launcher extends Activity content.setCurrentPage(content.getNextPage()); mAppsCustomizeContent.updateCurrentPageScroll(); + + // This can hold unnecessary references to views. + mStateAnimation = null; } }); @@ -3896,8 +3903,16 @@ public class Launcher extends Activity @Override public void onTrimMemory(int level) { super.onTrimMemory(level); - if (level >= ComponentCallbacks2.TRIM_MEMORY_MODERATE) { - mAppsCustomizeTabHost.onTrimMemory(); + if (level >= ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN) { + // The widget preview db can result in holding onto over + // 3MB of memory for caching which isn't necessary. + SQLiteDatabase.releaseMemory(); + + // We reset the apps customize tray in order to + // to free all the memory associated with widget previews + if (mAppsCustomizeTabHost != null) { + mAppsCustomizeTabHost.reset(); + } } } |