我有以下代码:
private Bitmap mBitmap;
private Canvas mCanvas;
private Path mPath;
private Paint mBitmapPaint;
mBitmap = Bitmap.createBitmap(480, 800, Bitmap.Config.ARGB_8888);
mCanvas = new Canvas(mBitmap);
mPath = new Path();
mBitmapPaint = new Paint(Paint.DITHER_FLAG);
protected void onDraw(Canvas canvas) {
canvas.drawBitmap(mBitmap, 0, 0, mBitmapPaint);
canvas.drawPath(mPath, mRealPaint);
}
当我运行它时,它运行良好几页。然后在完成几张图片后,它会强制关闭,给出以下异常:
E/GraphicsJNI(493): VM won't let us allocate 921600 bytes
D/AndroidRuntime(493): Shutting down VM
W/dalvikvm(493): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
E/AndroidRuntime(493): FATAL EXCEPTION: main
E/AndroidRuntime(493): java.lang.OutOfMemoryError: bitmap size exceeds VM budget
我阅读了很多关于这个主题的帖子。将大堆更新为 true,但仍然无法正常工作。有人可以帮我告诉我在这里做错了什么吗?
更多错误:
W/webcore(541): Can't get the viewWidth after the first layout
D/webviewglue(541): nativeDestroy view: 0x40a7b8
I/Ads(541): onReceiveAd()
D/dalvikvm(541): GC_EXTERNAL_ALLOC freed 1943 objects / 219448 bytes in 227ms
D/dalvikvm(541): GC_EXTERNAL_ALLOC freed 707 objects / 100576 bytes in 159ms
E/ActivityThread(541): Failed to find provider info for com.google.plus.platform