I\'m analyzing memory usage of our app, and has found strange Drawables
, which constantly \"eats\" few megabytes of heap. Here are few screenshots from MAT:
I would guess they stay in memory because they are the default backgrounds for activities. Try specifying a different background in your theme and see if they are still there.
This picture from android.jar, which you have to include into your project. There are two squares with the vertical gradient. The first - from 0x000000 to 0x272d33, the second - from 0xe8e8e8 to 0xfafafa. You can find them in android.jar/res/drawable-nodpi/background_holo_dark.png and background_holo_light.png. Of course, you can get different results depending on your Android SDK version.
The preloaded drawables are loaded by Zygote.
ZygoteInit#preloadResources()
/**
* Load in commonly used resources, so they can be shared across
* processes.
*
* These tend to be a few Kbytes, but are frequently in the 20-40K
* range, and occasionally even larger.
*/
private static void preloadResources() {
final VMRuntime runtime = VMRuntime.getRuntime();
try {
mResources = Resources.getSystem();
mResources.startPreloading();
if (PRELOAD_RESOURCES) {
Log.i(TAG, "Preloading resources...");
long startTime = SystemClock.uptimeMillis();
TypedArray ar = mResources.obtainTypedArray(
com.android.internal.R.array.preloaded_drawables);
int N = preloadDrawables(runtime, ar);
ar.recycle();
Log.i(TAG, "...preloaded " + N + " resources in "
+ (SystemClock.uptimeMillis()-startTime) + "ms.");
startTime = SystemClock.uptimeMillis();
ar = mResources.obtainTypedArray(
com.android.internal.R.array.preloaded_color_state_lists);
N = preloadColorStateLists(runtime, ar);
ar.recycle();
Log.i(TAG, "...preloaded " + N + " resources in "
+ (SystemClock.uptimeMillis()-startTime) + "ms.");
}
mResources.finishPreloading();
} catch (RuntimeException e) {
Log.w(TAG, "Failure preloading resources", e);
}
}
You see, the preloaded drawables are com.android.internal.R.array.preloaded_drawables