I am getting a memory leak when replacing scenes and using CCTransitionFade.
This at least according to Visual Leak Detector (which I’m not that familiar with)
Am able to reproduce this, in a simple Hello World example, plus one additional CCScene to switch to.
Using shared director to replace scene:
CODE:
// Initiate transition to Exit scene
CCScene* exitScene = ExitScene::scene();
CCDirector::sharedDirector()->replaceScene(CCTransitionCrossFade::create(1.0f, exitScene ));
This does NOT happen when replacing scene without transition:
CCDirector::sharedDirector()->replaceScene(exitScene);
I am using latest cocos2d-x version (Cocos2d-2.0-x-2.0.3).
Can someone confirm this ?
Or am I using replaceScene method incorrectly ?
Or perhaps a case of Visual Leak Detector false alarm ?
Cheers !
Visual Leak Detector log:
WARNING: Visual Leak Detector detected memory leaks!
---------- Block 1 at 0x00B1EE88: 416 bytes ----------
Call Stack:
c:\users\lmendesx\git\samecolor_cocos2dx_new\samecolor\classes\scenes\splashscene.h (19): Samecolor.win32.exe!SplashScene::create + 0x47 bytes
c:\users\lmendesx\git\samecolor_cocos2dx_new\samecolor\classes\scenes\splashscene.cpp (13): Samecolor.win32.exe!SplashScene::scene + 0x5 bytes
c:\users\lmendesx\git\samecolor_cocos2dx_new\samecolor\classes\appdelegate.cpp (36): Samecolor.win32.exe!AppDelegate::applicationDidFinishLaunching + 0x5 bytes
c:\users\lmendesx\git\samecolor_cocos2dx_new\cocos2dx\platform\win32\ccapplication.cpp (47): libcocos2d.dll!cocos2d::CCApplication::run + 0xF bytes
c:\users\lmendesx\git\samecolor_cocos2dx_new\samecolor\proj.win32\main.cpp (30): Samecolor.win32.exe!wWinMain + 0x19 bytes
f:\dd\vctools\crt_bld\self_x86\crt\src\crtexe.c (547): Samecolor.win32.exe!__tmainCRTStartup + 0x2C bytes
f:\dd\vctools\crt_bld\self_x86\crt\src\crtexe.c (371): Samecolor.win32.exe!wWinMainCRTStartup
0x751F339A (File and line number not available): kernel32.dll!BaseThreadInitThunk + 0x12 bytes
0x77579EF2 (File and line number not available): ntdll.dll!RtlInitializeExceptionChain + 0x63 bytes
0x77579EC5 (File and line number not available): ntdll.dll!RtlInitializeExceptionChain + 0x36 bytes
Data:
5C BC 20 01 57 02 00 00 00 00 00 00 01 00 00 00 \...W... ........
00 CD CD CD 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........
00 00 80 3F 00 00 80 3F 88 2D AB 0F 58 02 00 00 ...?...? .-..X...
00 00 00 00 01 00 00 00 00 CD CD CD 00 00 00 00 ........ ........
00 00 00 00 00 00 00 00 00 00 00 00 48 F6 B1 00 ........ ....H...
00 00 00 00 00 00 00 00 01 CD CD CD 88 2D AB 0F ........ .....-..
59 02 00 00 00 00 00 00 01 00 00 00 00 CD CD CD Y....... ........
00 00 00 3F 00 00 00 3F 88 2D AB 0F 5A 02 00 00 ...?...? .-..Z...
00 00 00 00 01 00 00 00 00 CD CD CD 00 00 70 43 ........ ......pC
00 00 C8 43 9C 2D AB 0F 5B 02 00 00 00 00 00 00 ...C.-.. [.......
01 00 00 00 00 CD CD CD 00 00 F0 43 00 00 48 44 ........ ...C..HD
00 CD CD CD F8 DB B1 00 01 CD CD CD FF FF FF FF ........ ........
00 00 00 00 00 00 00 00 D8 B0 B1 00 00 00 00 00 ........ ........
08 00 00 00 48 9E B1 00 D0 9D B1 00 00 00 80 3F ....H... .......?
00 00 00 00 00 00 00 80 00 00 80 3F 00 00 00 00 ........ ...?....
00 00 00 00 CD CD CD CD CD CD CD CD CD CD CD CD ........ ........
---------- Block 2 at 0x067D06B8: 416 bytes ----------
Call Stack:
c:\users\lmendesx\git\samecolor_cocos2dx_new\samecolor\classes\scenes\exitscene.h (47): Samecolor.win32.exe!ExitScene::create + 0x47 bytes
c:\users\lmendesx\git\samecolor_cocos2dx_new\samecolor\classes\scenes\exitscene.h (37): Samecolor.win32.exe!ExitScene::scene + 0x5 bytes
c:\users\lmendesx\git\samecolor_cocos2dx_new\samecolor\classes\scenes\splashscene.cpp (59): Samecolor.win32.exe!SplashScene::ccTouchesBegan + 0x5 bytes
c:\users\lmendesx\git\samecolor_cocos2dx_new\cocos2dx\touch_dispatcher\cctouchdispatcher.cpp (419): libcocos2d.dll!cocos2d::CCTouchDispatcher::touches + 0x2E bytes
c:\users\lmendesx\git\samecolor_cocos2dx_new\cocos2dx\touch_dispatcher\cctouchdispatcher.cpp (493): libcocos2d.dll!cocos2d::CCTouchDispatcher::touchesBegan
c:\users\lmendesx\git\samecolor_cocos2dx_new\cocos2dx\platform\cceglviewprotocol.cpp (224): libcocos2d.dll!cocos2d::CCEGLViewProtocol::handleTouchesBegin + 0x1A bytes
c:\users\lmendesx\git\samecolor_cocos2dx_new\cocos2dx\platform\win32\cceglview.cpp (243): libcocos2d.dll!cocos2d::CCEGLView::WindowProc + 0x20 bytes
c:\users\lmendesx\git\samecolor_cocos2dx_new\cocos2dx\platform\win32\cceglview.cpp (78): libcocos2d.dll!cocos2d::_WindowProc + 0x20 bytes
0x74F562FA (File and line number not available): USER32.dll!gapfnScSendMessage + 0x332 bytes
0x74F56D3A (File and line number not available): USER32.dll!GetThreadDesktop + 0xD7 bytes
0x74F60D27 (File and line number not available): USER32.dll!GetClientRect + 0xC5 bytes
0x74F60D4D (File and line number not available): USER32.dll!CallWindowProcW + 0x1B bytes
0x18F560FB (File and line number not available): OPENGL32.dll!wglSwapBuffers + 0x2DA bytes
0x74F562FA (File and line number not available): USER32.dll!gapfnScSendMessage + 0x332 bytes
0x74F56D3A (File and line number not available): USER32.dll!GetThreadDesktop + 0xD7 bytes
0x74F577C4 (File and line number not available): USER32.dll!CharPrevW + 0x138 bytes
0x74F5788A (File and line number not available): USER32.dll!DispatchMessageW + 0xF bytes
c:\users\lmendesx\git\samecolor_cocos2dx_new\cocos2dx\platform\win32\ccapplication.cpp (86): libcocos2d.dll!cocos2d::CCApplication::run + 0xC bytes
c:\users\lmendesx\git\samecolor_cocos2dx_new\samecolor\proj.win32\main.cpp (30): Samecolor.win32.exe!wWinMain + 0x19 bytes
f:\dd\vctools\crt_bld\self_x86\crt\src\crtexe.c (547): Samecolor.win32.exe!__tmainCRTStartup + 0x2C bytes
f:\dd\vctools\crt_bld\self_x86\crt\src\crtexe.c (371): Samecolor.win32.exe!wWinMainCRTStartup
0x751F339A (File and line number not available): kernel32.dll!BaseThreadInitThunk + 0x12 bytes
0x77579EF2 (File and line number not available): ntdll.dll!RtlInitializeExceptionChain + 0x63 bytes
0x77579EC5 (File and line number not available): ntdll.dll!RtlInitializeExceptionChain + 0x36 bytes
Data:
5C BE 20 01 DE 03 00 00 00 00 00 00 01 00 00 00 \....... ........
00 CD CD CD 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........
00 00 80 3F 00 00 80 3F 88 2D AB 0F DF 03 00 00 ...?...? .-......
00 00 00 00 01 00 00 00 00 CD CD CD 00 00 00 00 ........ ........
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........
00 00 00 00 00 00 00 00 01 CD CD CD 88 2D AB 0F ........ .....-..
E0 03 00 00 00 00 00 00 01 00 00 00 00 CD CD CD ........ ........
00 00 00 3F 00 00 00 3F 88 2D AB 0F E1 03 00 00 ...?...? .-......
00 00 00 00 01 00 00 00 00 CD CD CD 00 00 70 43 ........ ......pC
00 00 C8 43 9C 2D AB 0F E2 03 00 00 00 00 00 00 ...C.-.. ........
01 00 00 00 00 CD CD CD 00 00 F0 43 00 00 48 44 ........ ...C..HD
01 CD CD CD 60 05 7D 06 01 CD CD CD FF FF FF FF ....`.}. ........
00 00 00 00 00 00 00 00 D8 B0 B1 00 00 00 00 00 ........ ........
08 00 00 00 48 9E B1 00 D0 9D B1 00 00 00 80 3F ....H... .......?
00 00 00 00 00 00 00 80 00 00 80 3F 00 00 00 00 ........ ...?....
00 00 00 00 CD CD CD CD CD CD CD CD CD CD CD CD ........ ........
Visual Leak Detector detected 2 memory leaks (904 bytes).
Largest number used: 904 bytes.
Total allocations: 904 bytes.
Visual Leak Detector is now exiting.
cocos2d: deallocing 0FB2BF00