ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • cocos2d-x : 윈도우 기반 메모리 릭 체크 매크로
    cocos2d-x 2013. 9. 30. 15:24

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

     

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

     

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

     

    #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();
    }

     

     

     

     

     

Designed by Tistory.