From 2aa911c01e940383dca0b1afbf58a3439aaa748a Mon Sep 17 00:00:00 2001 From: Hans Boehm Date: Fri, 12 Oct 2018 17:16:27 -0700 Subject: [PATCH] Remove NotificationVisibility storage pool Based on recent measurements, storage pools of small objects are generally not useful. We ran into this because growing ArrayDeques are potentially very unfriendly towards a generational GC, and racing recycle calls can cause it it grow beyond MAX_POOL_SIZE. This isn't a big deal, but there's no reason we should even be thinking about it. Test: Build and boot AOSP Change-Id: Icbda95e472e206c54f141129cc36ddc6d163b095 --- .../statusbar/NotificationVisibility.java | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/core/java/com/android/internal/statusbar/NotificationVisibility.java b/core/java/com/android/internal/statusbar/NotificationVisibility.java index ea0344d1dadff..a7203e7e17d2b 100644 --- a/core/java/com/android/internal/statusbar/NotificationVisibility.java +++ b/core/java/com/android/internal/statusbar/NotificationVisibility.java @@ -27,7 +27,6 @@ import java.util.Collection; public class NotificationVisibility implements Parcelable { private static final String TAG = "NoViz"; private static final int MAX_POOL_SIZE = 25; - private static ArrayDeque sPool = new ArrayDeque<>(MAX_POOL_SIZE); private static int sNexrId = 0; public String key; @@ -119,11 +118,6 @@ public class NotificationVisibility implements Parcelable { } private static NotificationVisibility obtain() { - synchronized (sPool) { - if (!sPool.isEmpty()) { - return sPool.poll(); - } - } return new NotificationVisibility(); } @@ -135,16 +129,7 @@ public class NotificationVisibility implements Parcelable { *

*/ public void recycle() { - if (key == null) { - // do nothing on multiple recycles - return; - } - key = null; - if (sPool.size() < MAX_POOL_SIZE) { - synchronized (sPool) { - sPool.offer(this); - } - } + // With a modern GC, this is no longer useful for objects this small. } /**