chopchop
chopchop

Reputation: 1933

Out of memory error on screen rotation with large Drawable

I have a bit of difficulties to understand memory issues with Android. The problem is that when I rotate the screen twice, I get an OutOfMemory error when allocating a WebView containing a large image. My image isn't even that big 936*682 24-bit PNG, 50.5 KB.

Here is my activity :

public class IndoorMapActivity extends Activity{

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.indoor_map);    
    }

}

In my layout, I basically only have a custom ImageWebView.

Here is the custom ImageWebView constructor:

public ImageWebView(Context context, AttributeSet attrs) {
    super(context, attrs);

    mContext = context;

    this.loadUrl("file:///android_res/drawable/ground.png");
    this.getSettings().setBuiltInZoomControls(true);
    this.getSettings().setDefaultZoom(WebSettings.ZoomDensity.MEDIUM);

}

Upvotes: 1

Views: 923

Answers (1)

Arnab Chakraborty
Arnab Chakraborty

Reputation: 7472

Apparently, this is a known bug in Android. You can find the details here. This issue has been fixed in Android 2.2.

Upvotes: 1

Related Questions