(Even though this was a year ago, I came here via Google)
Something tells me that you have too many views loaded at once and Android
can't keep track of them all. * This sounded like not using the ListView
correctly, which is something a lot of us are guilty of. Assuming that you have
a custom array adapter:
public abstract View getView (int position, View convertView, ViewGroup parent)
When you overload this function, always check convertView.
public abstract View getView (int position, View convertView, ViewGroup parent) { View view = convertView; if ( view == null ) { // create/inflate the view here //
ex: view = inflater.inflate(R.layout.bob, null);
// configure the static parts here } //
configure the dynamic parts here return view; }
Android has a "recycle bin" mechanism for listview views, and will reuse
views if all possible. In other words, instead of creating a bunch of different
views, it'll grab an old view from the recycle bin.
In your case, you have 10 different kind of views. If they are very similar,
you can make a superview and turn on or turn off parts of the view (example
being subView.setVisibility(View.GONE)). Just watch out for massive if statement
blocks. I haven't used these before, but you should investigate
public abstract int getItemViewType (int position) public abstract int getViewTypeCount ()
This would be better because you don't have to deal with extra fluff, and it
should be automatically managed by Android
-
Personally, I'm not 100% sure that this could be it, but I have the feeling
that there's a 66% chance it's this
Try extending your Activities so you can see if they are being garbage
collected (finalize() being called). Similarly, try extending your Views to help
identify if they are being garbage collected.
If you are putting Views and Activities into Collections for caching, trying
using collection objects that use WeakReference, such as WeakHashMap. Are you
using inner classes in your Views or Activities? If so, these classes holds a
reference to the Activity or View and prevent them from being garbage collected.
A good example is an AsyncTask that is an inner class. This task runs in its own
thread, and can continue to hold on to Views even when you have closed the
activity,
Also, look at static variables, are they holding on to objects?
This is problem from Surface Flinger, Which will maintain and compose
Surfaces of Application into display device.
try this : reduce your layout pixel format in xml file .