fixed memory leak cause by singleton.

This commit is contained in:
Dhilan007 2014-07-08 18:22:48 +08:00
parent e31abe3f54
commit 10defddc2e
3 changed files with 9 additions and 7 deletions

View File

@ -25,7 +25,6 @@ THE SOFTWARE.
****************************************************************************/ ****************************************************************************/
#include "2d/CCMenu.h" #include "2d/CCMenu.h"
#include "base/CCDirector.h" #include "base/CCDirector.h"
#include "CCApplication.h"
#include "base/CCTouch.h" #include "base/CCTouch.h"
#include "CCStdC.h" #include "CCStdC.h"
#include "base/CCEventListenerTouch.h" #include "base/CCEventListenerTouch.h"

View File

@ -177,7 +177,6 @@ Director::~Director(void)
CC_SAFE_RELEASE(_scheduler); CC_SAFE_RELEASE(_scheduler);
CC_SAFE_RELEASE(_actionManager); CC_SAFE_RELEASE(_actionManager);
delete _eventAfterUpdate; delete _eventAfterUpdate;
delete _eventAfterDraw; delete _eventAfterDraw;
delete _eventAfterVisit; delete _eventAfterVisit;
@ -191,12 +190,11 @@ Director::~Director(void)
CC_SAFE_RELEASE(_eventDispatcher); CC_SAFE_RELEASE(_eventDispatcher);
// clean auto release pool
PoolManager::destroyInstance();
// delete _lastUpdate // delete _lastUpdate
CC_SAFE_DELETE(_lastUpdate); CC_SAFE_DELETE(_lastUpdate);
Configuration::destroyInstance();
s_SharedDirector = nullptr; s_SharedDirector = nullptr;
} }
@ -976,7 +974,6 @@ void Director::purgeDirector()
GLProgramCache::destroyInstance(); GLProgramCache::destroyInstance();
GLProgramStateCache::destroyInstance(); GLProgramStateCache::destroyInstance();
FileUtils::destroyInstance(); FileUtils::destroyInstance();
Configuration::destroyInstance();
// cocos2d-x specific data structures // cocos2d-x specific data structures
UserDefault::destroyInstance(); UserDefault::destroyInstance();

View File

@ -27,6 +27,8 @@ THE SOFTWARE.
#define __CC_APPLICATION_PROTOCOL_H__ #define __CC_APPLICATION_PROTOCOL_H__
#include "base/CCPlatformMacros.h" #include "base/CCPlatformMacros.h"
#include "base/CCScriptSupport.h"
#include "base/CCAutoreleasePool.h"
NS_CC_BEGIN NS_CC_BEGIN
@ -61,7 +63,11 @@ public:
* @js NA * @js NA
* @lua NA * @lua NA
*/ */
virtual ~ApplicationProtocol() {} virtual ~ApplicationProtocol(){
ScriptEngineManager::destroyInstance();
// clean auto release pool
PoolManager::destroyInstance();
}
/** /**
@brief Implement Director and Scene init code here. @brief Implement Director and Scene init code here.