Note that there are some explanatory texts on larger screens.

plurals
  1. POOut of memory error when restarting app (Android)
    primarykey
    data
    text
    <p>I am working on an game that uses 5 large images that are around 900x600. When I exit the game(press the back button) and then try to launch the game, I get the following error: </p> <pre><code>12-29 15:59:16.633: E/AndroidRuntime(18642): FATAL EXCEPTION: GLThread 17 12-29 15:59:16.633: E/AndroidRuntime(18642): java.lang.OutOfMemoryError: (Heap Size=20423KB, Allocated=3473KB, Bitmap Size=77KB) 12-29 15:59:16.633: E/AndroidRuntime(18642): at org.andengine.opengl.util.GLHelper.getPixelsARGB_8888(GLHelper.java:165) 12-29 15:59:16.633: E/AndroidRuntime(18642): at org.andengine.opengl.util.GLHelper.getPixels(GLHelper.java:41) 12-29 15:59:16.633: E/AndroidRuntime(18642): at org.andengine.opengl.util.GLState.glTexImage2D(GLState.java:641) 12-29 15:59:16.633: E/AndroidRuntime(18642): at org.andengine.opengl.texture.bitmap.BitmapTexture.writeTextureToHardware(BitmapTexture.java:120) 12-29 15:59:16.633: E/AndroidRuntime(18642): at org.andengine.opengl.texture.Texture.loadToHardware(Texture.java:137) 12-29 15:59:16.633: E/AndroidRuntime(18642): at org.andengine.opengl.texture.TextureManager.updateTextures(TextureManager.java:254) 12-29 15:59:16.633: E/AndroidRuntime(18642): at org.andengine.engine.Engine.onDrawFrame(Engine.java:621) 12-29 15:59:16.633: E/AndroidRuntime(18642): at org.andengine.opengl.view.EngineRenderer.onDrawFrame(EngineRenderer.java:105) 12-29 15:59:16.633: E/AndroidRuntime(18642): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1363) 12-29 15:59:16.633: E/AndroidRuntime(18642): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1118) </code></pre> <p>This is really perplexing since I unload all the textures before the application is destroyed. I know these 5 images are causing the error because when I skipped loading them altogether, I did not get any errors. To make sure all textures were unloaded, I loaded the textures and right after unloaded them. I then exited and relaunched the game but received the same error. The textures do not have any static references either. I also used the MAT to see how much memory I was using in game and noticed that I was only using 2.5MB, so I have no idea why the error is saying "heap size = 20MB." The only way I have managed to solve the error for the time being is to include</p> <pre><code>system.exit(0); </code></pre> <p>which I know I shouldn't be using, but I am completely out of ideas.</p> <p>EDIT: I made sure the textures were being unloaded. I had a button in game that would unload all the textures. When I pressed it all the textures went black which I assume unloaded the textures. The general approach I used when unloading textures was just to say</p> <pre><code>someTexture.unload(); </code></pre> <p>which is an andEngine method. I'm not sure what happens beyond that.</p> <p>EDIT 2: I am loading the textures in a method called onCreateResources() and I unload them onDestroy(). Those are the only two places I manipulate the textures. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload