My friend was quoting as said below. Can somebody validate his
statement whether it is true.
My Friends Quote :
Apparently there is a problem in UI Framework with drawable resources
management. If an activity uses a layout with an image file statically
linked
as background (and possibly some other attributes), every time the
activity is
created, a new bitmap object is generated and never gets released,
which
eventually leads to out of memory exception.
I created a simple test app, which uses a really big png file (850Kb,
1650x1275px) set as background in the activity's main layout xml.
After two
attempts of screen orientation change, on which event the activity
gets
destroyed and then recreated, the application crashed with the subject
exception. Recycling the background bitmap object in the activity
onDestory()
method, like shown below, solved the problem.
protected void onDestroy() {
super.onDestroy();
LinearLayout theView = (LinearLayout)findViewById
(R.id.main_layout);
BitmapDrawable theBitmap = (BitmapDrawable)
theView.getBackground();
theBitmap.getBitmap().recycle();
}
So we either need to fix it on the framework side, so that when an
activity is
destroyed, all drawable objects associated with it are released as
well, or we
need to make sure that all static images are handled by all the
applications in
a proper way and all drawables are recycled explicitly.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---