2.2.3用vld检测出cocostudio内存泄漏

想请教下各位是怎么解决这些问题的?
谢谢!

代码非常简单,就创建一个空的工程,然后添加:
#ifdef WIN32
#include “vld.h”
#endif

using namespace ui;
HelloWorld::~HelloWorld()
{
GUIReader::shareReader()->purge();
SceneReader::sharedSceneReader()->purge();
ActionManager::purge();
CCArmatureDataManager::sharedArmatureDataManager()->purge();
}

bool HelloWorld::init()
{
//////////////////////////////
// 1. super init first
if ( !CCLayer::init() )
{
return false;
}
UILayer* uiLayer = UILayer::create();
uiLayer->addWidget(GUIReader::shareReader()->widgetFromJsonFile(“NewUi_1.ExportJson”));
addChild(uiLayer);
return true;
}

NewUi_1.ExportJson就是一个ui工程里面添加一张图片,见附件

关闭程序后就可以看到有106处内存泄漏,可以看附件。
前104处泄漏是一些控件的单例,其实我没看懂为啥要创建这些单例。

后面两处是加载NewUi_1.ExportJson工程带来的,我只贴出了最后两处泄漏:
---------- Block 655 at 0x05BB7CF8: 24 bytes ----------
Call Stack:
c:\workspace\cocos2d-x-2.2.3\extensions\cocostudio\reader\widgetreader\imageviewreader\imageviewreader.cpp (26): test.exe!cocos2d::extension::ImageViewReader::getInstance + 0x7 bytes
c:\workspace\cocos2d-x-2.2.3\extensions\cocostudio\reader\widgetreader\imageviewreader\imageviewreader.cpp (10): test.exe!cocos2d::extension::ImageViewReader::createInstance + 0x23 bytes
c:\workspace\cocos2d-x-2.2.3\extensions\cocostudio\trigger\objectfactory.cpp (178): test.exe!cocos2d::extension::ObjectFactory::createWidgetReaderProtocol + 0x5 bytes
c:\workspace\cocos2d-x-2.2.3\extensions\cocostudio\reader\guireader.cpp (1013): test.exe!cocos2d::extension::WidgetPropertiesReader0300::widgetFromJsonDictionary + 0x3A bytes
c:\workspace\cocos2d-x-2.2.3\extensions\cocostudio\reader\guireader.cpp (1097): test.exe!cocos2d::extension::WidgetPropertiesReader0300::widgetFromJsonDictionary + 0x16 bytes
c:\workspace\cocos2d-x-2.2.3\extensions\cocostudio\reader\guireader.cpp (972): test.exe!cocos2d::extension::WidgetPropertiesReader0300::createWidget + 0x16 bytes
c:\workspace\cocos2d-x-2.2.3\extensions\cocostudio\reader\guireader.cpp (223): test.exe!cocos2d::extension::GUIReader::widgetFromJsonFile + 0x2C bytes
c:\workspace\cocos2d-x-2.2.3\projects\test\classes\helloworldscene.cpp (86): test.exe!HelloWorld::init + 0x11 bytes
c:\workspace\cocos2d-x-2.2.3\projects\test\classes\helloworldscene.h (25): test.exe!HelloWorld::create + 0xAE bytes
c:\workspace\cocos2d-x-2.2.3\projects\test\classes\helloworldscene.cpp (17): test.exe!HelloWorld::scene + 0x5 bytes
c:\workspace\cocos2d-x-2.2.3\projects\test\classes\appdelegate.cpp (28): test.exe!AppDelegate::applicationDidFinishLaunching + 0x5 bytes
c:\workspace\cocos2d-x-2.2.3\cocos2dx\platform\win32\ccapplication.cpp (47): libcocos2d.dll!cocos2d::CCApplication::run + 0xF bytes
c:\workspace\cocos2d-x-2.2.3\projects\test\proj.win32\main.cpp (20): test.exe!wWinMain + 0x2A bytes
f:\dd\vctools\crt_bld\self_x86\crt\src\crtexe.c (547): test.exe!__tmainCRTStartup + 0x2C bytes
f:\dd\vctools\crt_bld\self_x86\crt\src\crtexe.c (371): test.exe!wWinMainCRTStartup
0x7643338A (File and line number not available): kernel32.dll!BaseThreadInitThunk + 0x12 bytes
0x77679F72 (File and line number not available): ntdll.dll!RtlInitializeExceptionChain + 0x63 bytes
0x77679F45 (File and line number not available): ntdll.dll!RtlInitializeExceptionChain + 0x36 bytes
Data:
04 13 2B 01 8D 00 00 00 00 00 00 00 01 00 00 00 …+… …
00 00 00 00 F8 12 2B 01 …+. …

---------- Block 644 at 0x05BBBA28: 24 bytes ----------
Call Stack:
c:\workspace\cocos2d-x-2.2.3\extensions\cocostudio\reader\widgetreader\layoutreader\layoutreader.cpp (26): test.exe!cocos2d::extension::LayoutReader::getInstance + 0x7 bytes
c:\workspace\cocos2d-x-2.2.3\extensions\cocostudio\reader\widgetreader\layoutreader\layoutreader.cpp (10): test.exe!cocos2d::extension::LayoutReader::createInstance + 0x23 bytes
c:\workspace\cocos2d-x-2.2.3\extensions\cocostudio\trigger\objectfactory.cpp (178): test.exe!cocos2d::extension::ObjectFactory::createWidgetReaderProtocol + 0x5 bytes
c:\workspace\cocos2d-x-2.2.3\extensions\cocostudio\reader\guireader.cpp (1013): test.exe!cocos2d::extension::WidgetPropertiesReader0300::widgetFromJsonDictionary + 0x3A bytes
c:\workspace\cocos2d-x-2.2.3\extensions\cocostudio\reader\guireader.cpp (972): test.exe!cocos2d::extension::WidgetPropertiesReader0300::createWidget + 0x16 bytes
c:\workspace\cocos2d-x-2.2.3\extensions\cocostudio\reader\guireader.cpp (223): test.exe!cocos2d::extension::GUIReader::widgetFromJsonFile + 0x2C bytes
c:\workspace\cocos2d-x-2.2.3\projects\test\classes\helloworldscene.cpp (86): test.exe!HelloWorld::init + 0x11 bytes
c:\workspace\cocos2d-x-2.2.3\projects\test\classes\helloworldscene.h (25): test.exe!HelloWorld::create + 0xAE bytes
c:\workspace\cocos2d-x-2.2.3\projects\test\classes\helloworldscene.cpp (17): test.exe!HelloWorld::scene + 0x5 bytes
c:\workspace\cocos2d-x-2.2.3\projects\test\classes\appdelegate.cpp (28): test.exe!AppDelegate::applicationDidFinishLaunching + 0x5 bytes
c:\workspace\cocos2d-x-2.2.3\cocos2dx\platform\win32\ccapplication.cpp (47): libcocos2d.dll!cocos2d::CCApplication::run + 0xF bytes
c:\workspace\cocos2d-x-2.2.3\projects\test\proj.win32\main.cpp (20): test.exe!wWinMain + 0x2A bytes
f:\dd\vctools\crt_bld\self_x86\crt\src\crtexe.c (547): test.exe!__tmainCRTStartup + 0x2C bytes
f:\dd\vctools\crt_bld\self_x86\crt\src\crtexe.c (371): test.exe!wWinMainCRTStartup
0x7643338A (File and line number not available): kernel32.dll!BaseThreadInitThunk + 0x12 bytes
0x77679F72 (File and line number not available): ntdll.dll!RtlInitializeExceptionChain + 0x63 bytes
0x77679F45 (File and line number not available): ntdll.dll!RtlInitializeExceptionChain + 0x36 bytes
Data:
24 11 2B 01 82 00 00 00 00 00 00 00 01 00 00 00 $.+… …
00 00 00 00 18 11 2B 01 …+. …

Visual Leak Detector detected 106 memory leaks (7336 bytes).
Largest number used: 145474 bytes.
Total allocations: 180528 bytes.
Visual Leak Detector is now exiting.

我记得以前谁说过cocostudio每次版本前都会用vld测试的,难道上面这些泄漏其它人没有?

过来帮你顶起来

这个要顶啊,目前最头疼的问题啊,,求官方解决啊

可能是单例报的吧。

像是单例,但是这些单例怎么销毁呢?
win32下一般会用vlc来检测内存泄漏的,所以即使是单例,一般也会释放的接口吧

你好,建议你拿这个和一个新工程对比,因为游戏单例是伴随整个游戏的。