Open sourceBreaker opened 13 years ago
Is there any backtrace and source code? I have no Nexus to test...
2011/7/14 sourceBreaker < reply@reply.github.com>
Hi, My Game is crashing on CCtextureCache.createBitmap on Nexus Devices but working fine on all other devices even it is crashing on Nexus S and not crashing on LG Optimus. What is happening . Anyone please help me.
Reply to this email directly or view it on GitHub: https://github.com/ZhouWeikuan/cocos2d/issues/23
Post the stack trace and we might be able to help you
Hi following are the stack traces:
*****java.lang.OutOfMemoryError: bitmap size exceeds VM budget
at android.graphics.Bitmap.nativeCreate(Native Method)
at android.graphics.Bitmap.createBitmap(Bitmap.java:468)
at org.cocos2d.opengl.CCTexture2D.initWithImage(CCTexture2D.java:232)
at org.cocos2d.nodes.CCTextureCache$3.load(CCTextureCache.java:314)
at org.cocos2d.opengl.CCTexture2D.setLoader(CCTexture2D.java:194)
at org.cocos2d.nodes.CCTextureCache.createTextureFromFilePathExternal(CCTextureCache.java:295)
at org.cocos2d.nodes.CCTextureCache.addImage(CCTextureCache.java:70)
at org.cocos2d.nodes.CCSprite.
I Have 2 Activities and during gameplay i switches from One Activity to other multiple times when i switch from One Activity to second Activity i execute this code
CCDirector.sharedDirector().pause();
MyGameLayer().removeAllChildren(true);
MyGameLayer.destroy();
MYSpriteSheetParser.getInstance().destroy();
GLResourceHelper.sharedHelper().removeAllLoader(); // I remove all loader from reload queue
CCActionManager.sharedManager().removeAllActions();
CCActionManager.purgeSharedManager();
CCScheduler.sharedScheduler().unscheduleAllSelectors();
CCScheduler.purgeSharedScheduler();
CCTextureCache.sharedTextureCache().removeAllTextures();
CCTextureCache.purgeSharedTextureCache();
Now on Second Activity "OnCreate()" i make a new Scene , a new GLsurfaceView and CCDirectore.runWithScene() On all other devices my Game is running smooth and my Native memory is managed but in case of Nexus it crash on switching 2nd or 3rd Activity even my VM Native Heap memory is 16~20MB. (Note: if i don`t release textures my memory goes)
If you got any Suggestion please do reply me it will be very helpful for me because iPhone cocos have never cause me such problem.Is there any leak with GL?
Just wonder why not use two scenes to switch between levels? It might save up much space.
Thanks, Weikuan Zhou
2011/7/15 sourceBreaker < reply@reply.github.com>
Hi following are the stack traces:
*****java.lang.OutOfMemoryError: bitmap size exceeds VM budget at android.graphics.Bitmap.nativeCreate(Native Method) at android.graphics.Bitmap.createBitmap(Bitmap.java:468) at org.cocos2d.opengl.CCTexture2D.initWithImage(CCTexture2D.java:232) at org.cocos2d.nodes.CCTextureCache$3.load(CCTextureCache.java:314) at org.cocos2d.opengl.CCTexture2D.setLoader(CCTexture2D.java:194) at org.cocos2d.nodes.CCTextureCache.createTextureFromFilePathExternal(CCTextureCache.java:295) at org.cocos2d.nodes.CCTextureCache.addImage(CCTextureCache.java:70) at org.cocos2d.nodes.CCSprite.
(CCSprite.java:369) at org.cocos2d.nodes.CCSprite.sprite(CCSprite.java:270) at com.game.UI.uiobjects.UIObject.addSprite(UIObject.java:191) I Have 2 Activities and during gameplay i switches from One Activity to other multiple times when i switch from One Activity to second Activity i execute this code
CCDirector.sharedDirector().pause(); MyGameLayer().removeAllChildren(true); MyGameLayer.destroy(); MYSpriteSheetParser.getInstance().destroy(); GLResourceHelper.sharedHelper().removeAllLoader(); // I
remove all loader from reload queue CCActionManager.sharedManager().removeAllActions(); CCActionManager.purgeSharedManager(); CCScheduler.sharedScheduler().unscheduleAllSelectors(); CCScheduler.purgeSharedScheduler(); CCTextureCache.sharedTextureCache().removeAllTextures(); CCTextureCache.purgeSharedTextureCache();
Now on Second Activity "OnCreate()" i make a new Scene , a new GLsurfaceView and CCDirectore.runWithScene() On all other devices my Game is running smooth and my Native memory is managed but in case of Nexus it crash on switching 2nd or 3rd Activity even my VM Native Heap memory is 16~20MB. (Note: if i don`t release textures my memory goes)
- I am using 2 Activities for Levels in Games , When a Level is completed i switch activity and load other level in second activity so that previous memory get released , because if i dnt switch activity my memory don`t get released. See issue https://github.com/ZhouWeikuan/cocos2d/issues/22 *
If you got any Suggestion please do reply me it will be very helpful for me because iPhone cocos have never cause me such problem.Is there any leak with GL?
Reply to this email directly or view it on GitHub: https://github.com/ZhouWeikuan/cocos2d/issues/23#issuecomment-1578504
I agree with ZhouWeikuan, not only will it save space, but it is the intended use case for this operation in Cocos2d.
If the problem persists after making such changes then it may be reason for concern. I haven't had this issue when using one Activity and multiple scenes.
The only way to be sure what's happening is to profile your application and see where your memory is being budgeted. Also, this error seems to me that it only pertains to the Bitmap you are trying to load. Keep in mind that there is a physical limit for textures in that they can be no larger than 2048 x 2048.
Hope that helps!
Hi, My Game is crashing on CCtextureCache.createBitmap on Nexus Devices but working fine on all other devices even it is crashing on Nexus S and not crashing on LG Optimus. What is happening . Anyone please help me.