Locating and remedying cause of large heap size Locating and remedying cause of large heap size android android

Locating and remedying cause of large heap size


The system will preload the default system resources, this is independent of your app resources, things like standard Drawables for check boxes and radio buttons. 10.5MB does seem large but there are a lot of default system resources and the Images are bigger once stored in memory. Preloading is not new, but the size of preload could be larger in ICS. Display density probably plays a part in this along with simply the addition of more system Drawables preloaded in ICS.

There is currently no way to reduce the memory held by the sPreloadedDrawables

It is unfortunate that there isn't a way to clear this after the app process is spawned for apps (especially games) that don't use most of the system Drawables. In this case though the large size of the preload resources seems to have been a bug with a specific release (or handset port) of ICS. It is otherwise normally a small amount of memory, so I doubt it would ever be necessary to have such a mechanism to reduce the preload memory use.

If you are running out of memory as a result of this cache then I'd probably file a bug report to Google.

You can trace through the resource preload process here if you are interested in more internal details. ZygoteInit.preloadResources