Game crash on Android (memory leak in cocos2dx 2.1.2 ? )


#1

Hi,

after running my game successfully on Windows and iOS with cocos2dx 2.1.2 i’ve upgraded my Android Project from 2.0.4 to 2.1.2.
No I have the following problem: Every time i’m opening a GameScene the game crashes. The Game runs fine as long as i’m in the menu of the game.
The strange thing: From time to time i’m able to load some levels. How is this possible? Sound like a memory leak for me….

Here are some NDK Stack traces: I often get CCLog Line 44 as source of evil…. Can somebody explain me this?

* Crash dump:*
Build fingerprint: ‘generic/sdk/generic:4.1.2/MASTER/495790:eng/test-keys’
pid: 569, tid: 582, name: UNKNOWN >>> org.SearchLightGames.Blackout <<<
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00000000
Stack frame #00 pc 00177f68 /data/data/org.SearchLightGames.Blackout/lib/libgame.so (GameObjectWithSprite::init(Game**, Physik**, cocos2d::CCPoint, cocos2d::CCPoint, cocos2d::CCSprite**, int, float, float, cocos2d::CCString**)+83): Routine init in jni/…/…/Classes/GameObjectWithSprite.cpp:34
Stack frame #01 pc 001f8ed5 /data/data/org.SearchLightGames.Blackout/lib/libgame.so (cocos2d::CCLog(char const**, …)+72): Routine CCLog in C:/Users/EAGLE/Desktop/Progen/elcipse_Workspace/cocos2d-2.1rc0-x-2.1.2/blackout/proj.android/…/…/cocos2dx/platform/android/CCCommon.cpp:44
Crash dump is completed
* Crash dump:*
Build fingerprint: ‘generic/sdk/generic:4.1.2/MASTER/495790:eng/test-keys’
pid: 592, tid: 605, name: UNKNOWN >>> org.SearchLightGames.Blackout <<<
signal 11 , code 1 , fault addr 00000000
Stack frame #00 pc 00177f68 /data/data/org.SearchLightGames.Blackout/lib/libgame.so +83): Routine init in jni/…/…/Classes/GameObjectWithSprite.cpp:34
Stack frame #01 pc 001f8ed5 /data/data/org.SearchLightGames.Blackout/lib/libgame.so +72): Routine CCLog in C:/Users/EAGLE/Desktop/Progen/elcipse_Workspace/cocos2d-2.1rc0-x-2.1.2/blackout/proj.android/…/…/cocos2dx/platform/android/CCCommon.cpp:44
Crash dump is completed
* Crash dump:*
Build fingerprint: ‘generic/sdk/generic:4.1.2/MASTER/495790:eng/test-keys’
pid: 616, tid: 629, name: UNKNOWN >>> org.SearchLightGames.Blackout <<<
signal 11 , code 2 , fault addr 44eef000
Stack frame #00 pc 03988000 /dev/ashmem/dalvik-heap
Stack frame #01 pc 00188e73 /data/data/org.SearchLightGames.Blackout/lib/libgame.so +302): Routine update in jni/…/…/Classes/Physik.cpp:80
The last one seems like a classical memory leak…. But anyway here is the unsuspicious Code around Line 80 of Physik….

if != NULL) {
GameObject** unrawType = (GameObject**) b~~>GetUserData;
GameObjectWithSprite* gows = dynamic_cast<GameObjectWithSprite*>;
if {
CCSprite* sprite = unrawType)>getSprite;
if {
if < 0){
respawn));
break;
}
sprite
>setPosition.x * PTM_RATIO,
b~~>GetPosition.y** PTM_RATIO)); // LINE 80
sprite~~>setRotation) *~~1);
}
}
}

When i have a lock at Logcat it’s screaming like hell:

04-23 09:29:29.131: D/dalvikvm(616): GC_CONCURRENT freed 433K, 6 free 11067K/11655K, paused 77ms+17ms, total 141ms
04-23 09:29:30.211: D/dalvikvm(616): GC_CONCURRENT freed 478K, 6 free 10985K/11655K, paused 78ms+19ms, total 147ms
04-23 09:29:31.811: D/dalvikvm(616): GC_CONCURRENT freed 427K, 6 free 10994K/11655K, paused 78ms+5ms, total 157ms
04-23 09:29:33.871: D/dalvikvm(616): GC_CONCURRENT freed 445K, 6 free 11035K/11655K, paused 78ms+5ms, total 139ms
04-23 09:29:33.871: D/dalvikvm(616): WAIT_FOR_CONCURRENT_GC blocked 20ms
04-23 09:29:35.573: D/dalvikvm(616): GC_CONCURRENT freed 436K, 6 free 10985K/11655K, paused 79ms+4ms, total 150ms
04-23 09:29:37.211: D/dalvikvm(616): GC_CONCURRENT freed 408K, 6 free 10994K/11655K, paused 78ms+24ms, total 166ms
04-23 09:29:38.804: D/dalvikvm(616): GC_CONCURRENT freed 431K, 6 free 11052K/11655K, paused 77ms+91ms, total 221ms
04-23 09:29:40.290: D/dalvikvm(616): GC_CONCURRENT freed 474K, 6 free 10985K/11655K, paused 77ms+5ms, total 141ms
04-23 09:29:41.871: D/dalvikvm(616): GC_CONCURRENT freed 426K, 6 free 10994K/11655K, paused 78ms+26ms, total 153ms
04-23 09:29:43.422: D/dalvikvm(616): GC_CONCURRENT freed 488K, 6 free 10995K/11655K, paused 77ms+7ms, total 135ms
04-23 09:29:46.051: D/dalvikvm(616): GC_CONCURRENT freed 426K, 6 free 11040K/11655K, paused 77ms+4ms, total 139ms
04-23 09:29:47.431: D/dalvikvm(616): GC_CONCURRENT freed 505K, 6 free 10996K/11655K, paused 78ms+5ms, total 137ms
04-23 09:29:47.431: D/dalvikvm(616): WAIT_FOR_CONCURRENT_GC blocked 21ms
04-23 09:29:48.531: D/dalvikvm(616): GC_CONCURRENT freed 460K, 6 free 10986K/11655K, paused 77ms+17ms, total 155ms
04-23 09:29:50.071: D/dalvikvm(616): GC_CONCURRENT freed 427K, 6 free 10994K/11655K, paused 80ms+5ms, total 157ms

I’ve found a old post with a (mostly) similar problem: http://www.cocos2d-x.org/boards/6/topics/7459 but with no solution posted….

As i already mentioned everything worked fine with cocos2dx 2.0.4.
Please guys I’m hanging on this problem now for decades, has anybody any idea.