Hi,
I’ve been porting one of my projects from 2.1.4 to 3.0.0, and noticed some memory leaks with visual leak detector.
To dismiss the origin coming from my own project “I’m sure there are issues there :)” tried it with the HelloCpp sample project and also got leaks.
It seems related to opengl, but my diagnose skills are limited
The changes to the project are only the following:
- Add windows sdk include path to VS2012 include path (VS2012 problem cannot link to Windows.h if not done): <pre>
$(WindowsSDK_IncludePath)
</pre> - Add vld library and include paths.
- Add vld header to AppDelegate.cpp: <pre>
#include <vld.h>
</pre>
Use case:
- run HelloCpp (win32 debug)
- terminate by pressing on screen “Quit” button
My specs:
- Windows 7 64bit
- VS2012 (win32 debug)
- cocos2dx & opengl info:
- <pre>
</pre>
cocos2d.x.version: 3.0-pre-alpha0
cocos2d.x.compiled_with_profiler: false
cocos2d.x.compiled_with_gl_state_cache: true
gl.vendor: NVIDIA Corporation
gl.renderer: NVS 3100M/PCIe/SSE2
gl.version: 3.3.0
gl.max_texture_size: 8192
gl.max_texture_units: 96
gl.supports_ETC: false
gl.supports_PVRTC: false
gl.supports_NPOT: true
gl.supports_BGRA8888: false
gl.supports_discard_framebuffer: false
gl.supports_vertex_array_object: true
Full VLD log:
WARNING: Visual Leak Detector detected memory leaks!
---------- Block 351 at 0x0068D998: 4 bytes ----------
Call Stack:
f:\git\cocos2d-x\cocos2dx\script_support\ccscriptsupport.cpp (143): HelloCpp.exe!cocos2d::ScriptEngineManager::getInstance + 0x7 bytes
f:\git\cocos2d-x\cocos2dx\cocoa\ccobject.cpp (59): HelloCpp.exe!cocos2d::Object::~Object + 0x5 bytes
f:\git\cocos2d-x\cocos2dx\platform\ccimagecommon_cpp.h (92): HelloCpp.exe!cocos2d::Image::~Image + 0x8 bytes
0x013FC2CB (File and line number not available): HelloCpp.exe!cocos2d::Image::`scalar deleting destructor' + 0x2B bytes
f:\git\cocos2d-x\cocos2dx\cocoa\ccobject.cpp (74): HelloCpp.exe!cocos2d::Object::release + 0x34 bytes
f:\git\cocos2d-x\cocos2dx\ccdirector.cpp (877): HelloCpp.exe!cocos2d::Director::createStatsLabel + 0xE bytes
f:\git\cocos2d-x\cocos2dx\ccdirector.cpp (363): HelloCpp.exe!cocos2d::Director::setOpenGLView
f:\git\cocos2d-x\samples\cpp\hellocpp\classes\appdelegate.cpp (29): HelloCpp.exe!AppDelegate::applicationDidFinishLaunching
f:\git\cocos2d-x\cocos2dx\platform\win32\ccapplication.cpp (47): HelloCpp.exe!cocos2d::Application::run + 0xF bytes
f:\git\cocos2d-x\samples\cpp\hellocpp\proj.win32\main.cpp (23): HelloCpp.exe!wWinMain + 0xC bytes
f:\dd\vctools\crt_bld\self_x86\crt\src\crtexe.c (528): HelloCpp.exe!__tmainCRTStartup + 0x15 bytes
f:\dd\vctools\crt_bld\self_x86\crt\src\crtexe.c (377): HelloCpp.exe!wWinMainCRTStartup
0x774333CA (File and line number not available): kernel32.dll!BaseThreadInitThunk + 0x12 bytes
0x77EB9ED2 (File and line number not available): ntdll.dll!RtlInitializeExceptionChain + 0x63 bytes
0x77EB9EA5 (File and line number not available): ntdll.dll!RtlInitializeExceptionChain + 0x36 bytes
Data:
00 00 00 00 ........ ........
---------- Block 1092 at 0x006D6980: 52 bytes ----------
Call Stack:
f:\git\cocos2d-x\cocos2dx\platform\cceglviewprotocol.cpp (219): HelloCpp.exe!cocos2d::EGLViewProtocol::handleTouchesBegin + 0x7 bytes
f:\git\cocos2d-x\cocos2dx\platform\win32\cceglview.cpp (360): HelloCpp.exe!cocos2d::EGLView::WindowProc + 0x1D bytes
f:\git\cocos2d-x\cocos2dx\platform\win32\cceglview.cpp (173): HelloCpp.exe!cocos2d::_WindowProc + 0x20 bytes
0x776362FA (File and line number not available): USER32.dll!gapfnScSendMessage + 0x332 bytes
0x77636D3A (File and line number not available): USER32.dll!GetThreadDesktop + 0xD7 bytes
0x77640D27 (File and line number not available): USER32.dll!GetClientRect + 0xC5 bytes
0x77640D4D (File and line number not available): USER32.dll!CallWindowProcW + 0x1B bytes
0x53E560FB (File and line number not available): OPENGL32.dll!wglSwapBuffers + 0x2DA bytes
0x776362FA (File and line number not available): USER32.dll!gapfnScSendMessage + 0x332 bytes
0x77636D3A (File and line number not available): USER32.dll!GetThreadDesktop + 0xD7 bytes
0x776377C4 (File and line number not available): USER32.dll!CharPrevW + 0x138 bytes
0x7763788A (File and line number not available): USER32.dll!DispatchMessageW + 0xF bytes
f:\git\cocos2d-x\cocos2dx\platform\win32\ccapplication.cpp (86): HelloCpp.exe!cocos2d::Application::run + 0xC bytes
f:\git\cocos2d-x\samples\cpp\hellocpp\proj.win32\main.cpp (23): HelloCpp.exe!wWinMain + 0xC bytes
f:\dd\vctools\crt_bld\self_x86\crt\src\crtexe.c (528): HelloCpp.exe!__tmainCRTStartup + 0x15 bytes
f:\dd\vctools\crt_bld\self_x86\crt\src\crtexe.c (377): HelloCpp.exe!wWinMainCRTStartup
0x774333CA (File and line number not available): kernel32.dll!BaseThreadInitThunk + 0x12 bytes
0x77EB9ED2 (File and line number not available): ntdll.dll!RtlInitializeExceptionChain + 0x63 bytes
0x77EB9EA5 (File and line number not available): ntdll.dll!RtlInitializeExceptionChain + 0x36 bytes
Data:
DC 42 59 01 60 00 00 00 00 00 00 00 02 00 00 00 .BY.`... ........
00 00 00 00 00 00 00 00 01 CD CD CD 55 75 D8 43 ........ ....Uu.C
00 E0 92 43 55 75 D8 43 00 E0 92 43 55 75 D8 43 ...CUu.C ...CUu.C
00 E0 92 43 ...C.... ........
Visual Leak Detector detected 2 memory leaks (128 bytes).
Largest number used: 10088377 bytes.
Total allocations: 11150939 bytes.
Visual Leak Detector is now exiting.
The program '[5624] HelloCpp.exe' has exited with code 0 (0x0).