Possible Duplicate:
Android: Strange out of memory issue while loading an image to a Bitmap object
java.lang.OutOfMemoryError: bitmap size exceeds VM budget - Android
First Activity
public class Main_AllLatestNews extends ListActivity
Second Activity (load 10 or more images)
@Override
protected void onDestroy() {
super.onDestroy();
unbindDrawables(findViewById(R.id.RootView));
System.gc();
}
private void unbindDrawables(View view) {
if (view.getBackground() != null) {
view.getBackground().setCallback(null);
}
if (view instanceof ViewGroup) {
for (int i = 0; i < ((ViewGroup) view).getChildCount(); i++) {
unbindDrawables(((ViewGroup) view).getChildAt(i));
}
((ViewGroup) view).removeAllViews();
}
}
I am using this to call image
if (!imagepath[i].toString().equals("no picture")) {
try {
aURL = new URL("http://www.orientaldaily.com.my/" + imagepath[i]);
URLConnection conn = aURL.openConnection();
conn.connect();
InputStream is = conn.getInputStream();
BufferedInputStream bis = new BufferedInputStream(is);
Bitmap bm = BitmapFactory.decodeStream(bis);
bis.close();
is.close();
imageview = (ImageView) findViewById(R.id.image_categoryallnewstitle);
imageview.setScaleType(ScaleType.CENTER_CROP);
imageview.setImageBitmap(bm);
} catch (IOException e) {
Log.e("DEBUGTAG", "Remote Image Exception", e);
}
}
I implement this method before i call those images but yet still got memory leak and
bitmap size exceeds VM budget
Any problem in my code or got other solutions to solve this?