본문 바로가기
Cocos2D-x

윈도우 환경에서 메모리 릭 체크 방법

by CodeDiver 2014. 9. 18.

출처: http://shader.tistory.com/162



1. cocos2d-x 엔진을 기반으로 윈도우에서 멀티플랫폼 게임을 만들시에 간단하게 메모리에 릭이 발생하는 것을 체크할 수 있습니다.

 

2. 기억력이 떨어져서 복사&붙여넣기 신공을 위해 여기에 백업합니다.

 

3. cocos2d-x 2.1.5 에서 디폴트로 4바이트 정도 메모리 이 있네요.

    (v2.0.4 에서도 4 Byte발생)

 

#include "main.h"
#include "AppDelegate.h"
#include "CCEGLView.h"

 

//------------------------------------------------------------------------

USING_NS_CC ;

 

//------------------------------------------------------------------------

#if defined( DEBUG ) || defined( _DEBUG )
#   define _CRTDBG_MAP_ALLOC
#   include <crtdbg.h>
#   define DEBUG_NORMALBLOCK new ( _NORMAL_BLOCK, __FILE__, __LINE__ )
#       ifdef new
#           undef new
#       endif // new
#   define new DEBUG_NORMALBLOCK
#endif // DEBUG

//------------------------------------------------------------------------


int APIENTRY _tWinMain(HINSTANCE hInstance,
                       HINSTANCE hPrevInstance,
                       LPTSTR    lpCmdLine,
                       int       nCmdShow)
{
#if defined( DEBUG ) || defined( _DEBUG )
    _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF  ) ;
#endif // DEBUG

 

    UNREFERENCED_PARAMETER( hInstance ) ;
    UNREFERENCED_PARAMETER( hPrevInstance ) ;
    UNREFERENCED_PARAMETER( lpCmdLine ) ;
    UNREFERENCED_PARAMETER( nCmdShow ) ;

 

    // create the application instance
    AppDelegate app ;
    CCEGLView* eglView = CCEGLView::sharedOpenGLView() ;
    eglView->setViewName( "MYGlowHockey by MrMoonKr in CoCoApps" ) ;
    eglView->setFrameSize( 1024, 768 ) ;
    eglView->setFrameZoomFactor( 0.7f ) ;
    return CCApplication::sharedApplication()->run();
}

 

 

 

 

 

'Cocos2D-x' 카테고리의 다른 글

Bitmap font 생성기  (0) 2014.10.27
ScrollView 간단 사용법  (0) 2014.10.06
Google Play Game Services SDK  (0) 2014.08.18
CCSpriteBatchNode  (0) 2014.08.14
Animation 구현  (0) 2014.08.14