Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 81e0c849 authored by Jorim Jaggi's avatar Jorim Jaggi
Browse files

Aggressive tuning of recents memory usage

Limit the thumbnail count to a maximum of 10 thumbnails and the app
icon count to a maximum of 20 thumbnails, instead of using a
byte-size based limit.

Also prune entries immediately when leaving recents.

Bug: 16513124
Change-Id: Id9a32f87ca3f9f19e5cad5f115d54b19b26f4f93
parent f3d0e475
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -29,6 +29,12 @@
     ImageView -->
    <bool name="config_recents_thumbnail_image_fits_to_xy">false</bool>

    <!-- The number of app thumbnails we keep in memory -->
    <integer name="config_recents_max_thumbnail_count">10</integer>

    <!-- The number of app icons we keep in memory -->
    <integer name="config_recents_max_icon_count">20</integer>

    <!-- Control whether status bar should distinguish HSPA data icon form UMTS
    data icon on devices -->
    <bool name="config_hspa_data_distinguishable">false</bool>
+1 −1
Original line number Diff line number Diff line
@@ -68,7 +68,7 @@ public class Constants {

        public static class RecentsTaskLoader {
            // XXX: This should be calculated on the first load
            public static final int PreloadFirstTasksCount = 5;
            public static final int PreloadFirstTasksCount = 6;
        }

        public static class TaskStackView {
+0 −6
Original line number Diff line number Diff line
@@ -25,10 +25,4 @@ class BitmapLruCache extends KeyStoreLruCache<Bitmap> {
    public BitmapLruCache(int cacheSize) {
        super(cacheSize);
    }

    @Override
    protected int computeSize(Bitmap b) {
        // The cache size will be measured in kilobytes rather than number of items
        return b.getAllocationByteCount();
    }
}
 No newline at end of file
+0 −8
Original line number Diff line number Diff line
@@ -25,12 +25,4 @@ class DrawableLruCache extends KeyStoreLruCache<Drawable> {
    public DrawableLruCache(int cacheSize) {
        super(cacheSize);
    }

    @Override
    protected int computeSize(Drawable d) {
        // The cache size will be measured in kilobytes rather than number of items
        // NOTE: this isn't actually correct, as the icon may be smaller
        int maxBytes = (d.getIntrinsicWidth() * d.getIntrinsicHeight() * 4);
        return maxBytes;
    }
}
 No newline at end of file
+0 −9
Original line number Diff line number Diff line
@@ -34,10 +34,6 @@ public class KeyStoreLruCache<V> {

    public KeyStoreLruCache(int cacheSize) {
        mCache = new LruCache<Integer, V>(cacheSize) {
            @Override
            protected int sizeOf(Integer taskId, V v) {
                return computeSize(v);
            }

            @Override
            protected void entryRemoved(boolean evicted, Integer taskId, V oldV, V newV) {
@@ -46,11 +42,6 @@ public class KeyStoreLruCache<V> {
        };
    }

    /** Computes the size of a value. */
    protected int computeSize(V value) {
        return 0;
    }

    /** Gets a specific entry in the cache. */
    final V get(Task.TaskKey key) {
        return mCache.get(key.id);
Loading