diff options
| author | Dianne Hackborn <hackbod@google.com> | 2011-09-12 16:59:06 -0700 |
|---|---|---|
| committer | Dianne Hackborn <hackbod@google.com> | 2011-09-12 17:04:32 -0700 |
| commit | ab0f485e64418eb22f0a1d89d7064902b381e9c2 (patch) | |
| tree | 7bef4b7465521764e51c3bfc38ebd8d41721852d /core/java/android/content/res | |
| parent | bd5c9768c4432c6cb2bfa5f521d49ff03c087ff8 (diff) | |
| download | frameworks_base-ab0f485e64418eb22f0a1d89d7064902b381e9c2.zip frameworks_base-ab0f485e64418eb22f0a1d89d7064902b381e9c2.tar.gz frameworks_base-ab0f485e64418eb22f0a1d89d7064902b381e9c2.tar.bz2 | |
Fix problems where we were allocating TypedArray when not needed.
Fixes up some recycling of TypedArray objects to reduce the
number we need to allocate during inflation etc.
Change-Id: I948dccc052997779001eaa99db2a710b04be01ae
Diffstat (limited to 'core/java/android/content/res')
| -rwxr-xr-x | core/java/android/content/res/Resources.java | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/core/java/android/content/res/Resources.java b/core/java/android/content/res/Resources.java index d7f901a..4f19010 100755 --- a/core/java/android/content/res/Resources.java +++ b/core/java/android/content/res/Resources.java @@ -72,6 +72,7 @@ public class Resources { static final String TAG = "Resources"; private static final boolean DEBUG_LOAD = false; private static final boolean DEBUG_CONFIG = false; + private static final boolean DEBUG_ATTRIBUTES_CACHE = false; private static final boolean TRACE_FOR_PRELOAD = false; private static final boolean TRACE_FOR_MISS_PRELOAD = false; @@ -104,6 +105,7 @@ public class Resources { private boolean mPreloading; /*package*/ TypedArray mCachedStyledAttributes = null; + RuntimeException mLastRetrievedAttrs = null; private int mLastCachedXmlBlockIndex = -1; private final int[] mCachedXmlBlockIds = { 0, 0, 0, 0 }; @@ -2167,6 +2169,10 @@ public class Resources { TypedArray attrs = mCachedStyledAttributes; if (attrs != null) { mCachedStyledAttributes = null; + if (DEBUG_ATTRIBUTES_CACHE) { + mLastRetrievedAttrs = new RuntimeException("here"); + mLastRetrievedAttrs.fillInStackTrace(); + } attrs.mLength = len; int fullLen = len * AssetManager.STYLE_NUM_ENTRIES; @@ -2177,6 +2183,15 @@ public class Resources { attrs.mIndices = new int[1+len]; return attrs; } + if (DEBUG_ATTRIBUTES_CACHE) { + RuntimeException here = new RuntimeException("here"); + here.fillInStackTrace(); + if (mLastRetrievedAttrs != null) { + Log.i(TAG, "Allocated new TypedArray of " + len + " in " + this, here); + Log.i(TAG, "Last retrieved attributes here", mLastRetrievedAttrs); + } + mLastRetrievedAttrs = here; + } return new TypedArray(this, new int[len*AssetManager.STYLE_NUM_ENTRIES], new int[1+len], len); |
