位图大小超过第二级VM预算

时间:2014-02-25 08:45:39

标签: android bitmap out-of-memory

我正在开发一款游戏,我试图从第一阶段进入第二阶段。 当我直接开始第二阶段时,它运行得很好,但是当我玩第一阶段并解锁第二阶段,然后开始第二阶段时,它显示错误:

02-25 14:07:09.923: ERROR/AndroidRuntime(409): FATAL EXCEPTION: GLThread 12
02-25 14:07:09.923: ERROR/AndroidRuntime(409): java.lang.OutOfMemoryError: bitmap size exceeds VM budget
02-25 14:07:09.923: ERROR/AndroidRuntime(409):     at android.graphics.Bitmap.nativeCreate(Native Method)
02-25 14:07:09.923: ERROR/AndroidRuntime(409):     at android.graphics.Bitmap.createBitmap(Bitmap.java:477)
02-25 14:07:09.923: ERROR/AndroidRuntime(409):     at android.graphics.Bitmap.createBitmap(Bitmap.java:444)
02-25 14:07:09.923: ERROR/AndroidRuntime(409):     at com.threed.jpct.util.BitmapHelper.rescale(BitmapHelper.java:72)
02-25 14:07:09.923: ERROR/AndroidRuntime(409):     at bones.samples.android.LevelTwo$MyRenderer.onSurfaceChanged(LevelTwo.java:555)
02-25 14:07:09.923: ERROR/AndroidRuntime(409):     at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1356)
02-25 14:07:09.923: ERROR/AndroidRuntime(409):     at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1118)

我无法理解这种情况,因为当我只运行一个阶段然后它们正确运行但是在第一个运行之后它不能运行。

Texture texture = new Texture(BitmapHelper.rescale(BitmapHelper.convert(getResources().getDrawable(R.d‌​rawable.bgtwo)), 512, 1024));
TextureManager.getInstance().addTexture("texture", texture);

0 个答案:

没有答案