示例#1
0
int main(void){
#ifdef _DEBUG
	_CrtMemState s1;
	_CrtMemCheckpoint( &s1 );
#endif
	vox::fullscreen = true;
	vox::initialize("DDOS");
	OJ_ResourceManager::init();
	OJ_ResourceManager::load();
	OJ_Game * game = new OJ_Game();

	while (game->isRunning){
		game->performGameLoop();
	}
	
	delete game;
	game = nullptr;
	OJ_ResourceManager::destruct();
#ifdef _DEBUG
	std::cout << "Final node count: " << Node::nodes.size() << std::endl;

	for(auto n : Node::nodes){
		std::cout << typeid(*n).name() << std::endl;
	}
#endif

	vox::destruct();
	
#ifdef _DEBUG
	_CrtMemDumpAllObjectsSince(&s1);
#endif
}
示例#2
0
void checkLeak()
{
#if (defined(WIN32) && defined(CHECK_LEAKS))
    _CrtSetReportMode( _CRT_WARN, _CRTDBG_MODE_FILE );
    _CrtSetReportFile( _CRT_WARN, _CRTDBG_FILE_STDERR );
    _CrtMemDumpAllObjectsSince(NULL);
#endif
}
int main(int argc, char *argv[])
{
    int             res;

#if defined(_MSC_VER) && \
    defined(_DEBUG)
    _CrtMemState    memState;
#endif /* _MSC_VER && _MSC_VER */

#if defined(_MSC_VER) && \
    defined(_DEBUG)
    _CrtMemCheckpoint(&memState);
#endif /* _MSC_VER && _MSC_VER */

#if 0
    { for(size_t i = 0; i < 0xffffffff; ++i){} }
#endif /* 0 */

    try
    {
#if defined(_DEBUG) || \
    defined(__SYNSOFT_DBS_DEBUG)
        puts("test.performance.one_pointer: " STLSOFT_COMPILER_LABEL_STRING);
#endif /* debug */

        if(fastformat::init() < 0)
        {
            fprintf(stderr, "Failed to initialise FastFormat\n");

            res = EXIT_FAILURE;
        }
        else
        {
            res = main_(argc, argv);

            fastformat::uninit();
        }
    }
    catch(std::exception& x)
    {
        fprintf(stderr, "Unhandled error: %s\n", x.what());

        res = EXIT_FAILURE;
    }
    catch(...)
    {
        fprintf(stderr, "Unhandled unknown error\n");

        res = EXIT_FAILURE;
    }

#if defined(_MSC_VER) && \
    defined(_DEBUG)
    _CrtMemDumpAllObjectsSince(&memState);
#endif /* _MSC_VER) && _DEBUG */

    return res;
}
示例#4
0
文件: Source.cpp 项目: Enelar/p2pvk
void main()
{
  //PrepareLogFunction(io);
  _CrtMemCheckpoint(&s1);
  t_f();
  _CrtMemDumpAllObjectsSince(&s1);
  Log("Exit sequence initiated");
  std::cout << std::endl << "== INITIATE EXIT SEQUENCE." << std::endl;
}
int main(int argc, char **argv)
{
    int retCode = EXIT_SUCCESS;
    int verbosity = 2;

#if defined(_MSC_VER) && \
    defined(_DEBUG)
    _CrtMemState    ms;
    _CrtMemCheckpoint(&ms);
#endif

    XTESTS_COMMANDLINE_PARSEVERBOSITY(argc, argv, &verbosity);

    if(XTESTS_START_RUNNER("test.unit.stlsoft.container.insert_ordered_map", verbosity))
    {
        XTESTS_RUN_CASE(test_ios_default_ctor);
        XTESTS_RUN_CASE(test_ios_size);
        XTESTS_RUN_CASE(test_ios_empty);
        XTESTS_RUN_CASE(test_ios_push_front);
        XTESTS_RUN_CASE(test_ios_push_back);
        XTESTS_RUN_CASE(test_ios_push_front_2);
        XTESTS_RUN_CASE(test_ios_push_back_2);
        XTESTS_RUN_CASE(test_ios_backinserter);
        XTESTS_RUN_CASE(test_ios_find_1);
        XTESTS_RUN_CASE(test_ios_erase_1);
        XTESTS_RUN_CASE(test_ios_erase_2);
        XTESTS_RUN_CASE(test_ios_erase_3);
        XTESTS_RUN_CASE(test_ios_erase_4);
        XTESTS_RUN_CASE(test_ios_clear_1);
        XTESTS_RUN_CASE(test_ios_clear_2);
        XTESTS_RUN_CASE(test_push_front_bulk);
        XTESTS_RUN_CASE(test_1_09);
        XTESTS_RUN_CASE(test_1_10);
        XTESTS_RUN_CASE(test_1_11);
        XTESTS_RUN_CASE(test_1_12);
        XTESTS_RUN_CASE(test_1_13);
        XTESTS_RUN_CASE(test_1_14);
        XTESTS_RUN_CASE(test_1_15);
        XTESTS_RUN_CASE(test_1_16);
        XTESTS_RUN_CASE(test_1_17);
        XTESTS_RUN_CASE(test_1_18);
        XTESTS_RUN_CASE(test_1_19);
        XTESTS_RUN_CASE(test_1_20);

        XTESTS_PRINT_RESULTS();

        XTESTS_END_RUNNER_UPDATE_EXITCODE(&retCode);
    }

#if defined(_MSC_VER) && \
    defined(_DEBUG)
    _CrtMemDumpAllObjectsSince(&ms);
#endif

    return retCode;
}
int main__(int argc, char** argv)
{
    _CrtMemState memState;

    _CrtMemCheckpoint(&memState);

    int r = main_(argc, argv);

    _CrtMemDumpAllObjectsSince(&memState);

    return r;
}
示例#7
0
    ~MemoryLeaks()
    {
        _CrtMemState checkpoint;

        _CrtMemCheckpoint(&checkpoint);

        _CrtMemState diff;
        _CrtMemDifference(&diff, &m_checkpoint, &checkpoint);

        _CrtMemDumpStatistics(&diff);
        _CrtMemDumpAllObjectsSince(&diff);
    }
示例#8
0
文件: sq.cpp 项目: apaikan/myCub
int sqrl_main(int argc, char* argv[])
{
    
	HSQUIRRELVM v;
	SQInteger retval = 0;
	const SQChar *filename=NULL;
#if defined(_MSC_VER) && defined(_DEBUG)
	_CrtSetAllocHook(MemAllocHook);
#endif
	
	v=sq_open(1024);
	sq_setprintfunc(v,printfunc,errorfunc);

	sq_pushroottable(v);
    
	sqstd_register_bloblib(v);    
	sqstd_register_iolib(v);
	sqstd_register_mathlib(v);
 	   
    /*
     * TODO: system and string library should be implemented for nuttx 
     *       they need 'longjmp' and 'setjmp'. 
     */   
    //sqstd_register_stringlib(v);    
    //sqstd_register_systemlib(v);

	//aux library
	//sets error handlers
	sqstd_seterrorhandlers(v);

	//gets arguments
	switch(getargs(v,argc,argv,&retval))
	{
	case _INTERACTIVE:
		Interactive(v);
		break;
	case _DONE:
	case _ERROR:
	default: 
		break;
	}

	sq_close(v);
	
#if defined(_MSC_VER) && defined(_DEBUG)
	_getch();
	_CrtMemDumpAllObjectsSince( NULL );
#endif
	return retval;
    
    return 0;
}
示例#9
0
// Cleanup the diagnostic framework before dumping any memory leaks.
//
int diagnostics_finish() {

#ifdef _WIN32

    // Shutdown the message monitor thread and handles
    diagnostics_finish_message_monitor();

    // Shutdown the unhandled exception filter thread and handles
    diagnostics_finish_unhandled_exception_monitor();

    // Cleanup internal thread list structures and free up any
    //   used memory.
    diagnostics_finish_thread_list();

#ifdef _DEBUG

    // Only perform the memory leak dump if it is a boinc application
    //   and not the BOINC Manager, BOINC Core Client, or BOINC
    //   Screen saver since they'll check on close.
    if (flags & BOINC_DIAG_BOINCAPPLICATION) {
        if (flags & BOINC_DIAG_MEMORYLEAKCHECKENABLED) {
            _CrtMemCheckpoint(&finish_snapshot);
            if (_CrtMemDifference(&difference_snapshot, &start_snapshot, &finish_snapshot)) {
                fprintf(stdout, "\n\n");
                fprintf(stdout, "**********\n");
                fprintf(stdout, "**********\n");
                fprintf(stdout, "\n");
                fprintf(stdout, "Memory Leaks Detected!!!\n");
                fprintf(stdout, "\n");
                fprintf(stdout, "Memory Statistics:\n");
                _CrtMemDumpStatistics(&difference_snapshot);
                fprintf(stdout, "\n");
                _CrtMemDumpAllObjectsSince(&difference_snapshot);
                fprintf(stdout, "\n");
            }
        }
    }

#endif // defined(_DEBUG)
#endif // defined(_WIN32)

#ifdef ANDROID
    if (libhandle) {
      dlclose(libhandle);
    }
#endif

    // Set initalization flag to false.
    diagnostics_initialized = false;

    return BOINC_SUCCESS;
}
示例#10
0
bool test_iphelp_api()
{
	_CrtMemState memoryState = { 0 };
	_CrtMemCheckpoint(&memoryState);

	{
		//if (0 != exec_iphelp_api_sample()) return false;
		//if (0 != exec_iphelp_api_sample2(AF_INET)) return false;
		//if (0 != exec_iphelp_api_sample2(AF_INET6)) return false;
	}
	
	_CrtMemDumpAllObjectsSince(&memoryState);
	return true;
}
int main(int argc, char *argv[])
{
    int             res;

#if defined(_MSC_VER) && \
    defined(_DEBUG)
    _CrtMemState    memState;
#endif /* _MSC_VER && _MSC_VER */

#if defined(_MSC_VER) && \
    defined(_DEBUG)
    _CrtMemCheckpoint(&memState);
#endif /* _MSC_VER && _MSC_VER */

    try
    {
        if(fastformat::init() < 0)
        {
            fprintf(stderr, "Failed to initialise FastFormat\n");

            res = EXIT_FAILURE;
        }
        else
        {
            res = main_(argc, argv);

            fastformat::uninit();
        }
    }
    catch(std::exception& x)
    {
        fprintf(stderr, "Unhandled error: %s\n", x.what());

        res = EXIT_FAILURE;
    }
    catch(...)
    {
        fprintf(stderr, "Unhandled unknown error\n");

        res = EXIT_FAILURE;
    }

#if defined(_MSC_VER) && \
    defined(_DEBUG)
    _CrtMemDumpAllObjectsSince(&memState);
#endif /* _MSC_VER) && _DEBUG */

    return res;
}
示例#12
0
文件: sq.c 项目: John-He-928/krkrz
int main(int argc, char* argv[])
{
	HSQUIRRELVM v;
	
	const SQChar *filename=NULL;
#if defined(_MSC_VER) && defined(_DEBUG)
	_CrtSetAllocHook(MemAllocHook);
#endif
	
	//v= sq_open(1024);
	v= sqobject::init();
	sq_setprintfunc(v,printfunc);

	sq_pushroottable(v);

	sqstd_register_bloblib(v);
	sqstd_register_iolib(v);
	sqstd_register_systemlib(v);
//	sqstd_register_mathlib(v);
//	sqstd_register_stringlib(v);

	//aux library
	//sets error handlers
//	sqstd_seterrorhandlers(v);

	sqobject::Object::registerClass();
	
	//gets arguments
	int ret;
	switch((ret = getargs(v,argc,argv)))
	{
	case _INTERACTIVE:
		Interactive(v);
		break;
	case _DONE:
	default: 
		break;
	}

	//sq_close(v);
	sqobject::done();
	
#if defined(_MSC_VER) && defined(_DEBUG)
	_getch();
	_CrtMemDumpAllObjectsSince( NULL );
#endif
	
	return ret == _ERROR ? -1 : 0;
}
int main(int argc, char *argv[])
{
    int             res;

#if defined(_MSC_VER) && \
    defined(_DEBUG)
    _CrtMemState    memState;
#endif /* _MSC_VER && _MSC_VER */

#if defined(_MSC_VER) && \
    defined(_DEBUG)
    _CrtMemCheckpoint(&memState);
#endif /* _MSC_VER && _MSC_VER */

#if 0
    {
        for(size_t i = 0; i < 0xffffffff; ++i) {}
    }
#endif /* 0 */

    try
    {
#if defined(_DEBUG) || \
    defined(__SYNSOFT_DBS_DEBUG)
#endif /* debug */

        res = main_(argc, argv);
    }
    catch(std::exception &x)
    {
        fprintf(stderr, "Unhandled error: %s\n", x.what());

        res = EXIT_FAILURE;
    }
    catch(...)
    {
        fprintf(stderr, "Unhandled unknown error\n");

        res = EXIT_FAILURE;
    }

#if defined(_MSC_VER) && \
    defined(_DEBUG)
    _CrtMemDumpAllObjectsSince(&memState);
#endif /* _MSC_VER) && _DEBUG */

    return res;
}
示例#14
0
int main(int argc, char** argv)
{
    int             res;

#if defined(_MSC_VER) && \
    defined(_DEBUG)
    _CrtMemState    memState;
#endif /* _MSC_VER && _MSC_VER */

#if defined(_MSC_VER) && \
    defined(_DEBUG)
    _CrtMemCheckpoint(&memState);
#endif /* _MSC_VER && _MSC_VER */

#if 0
    { for(size_t i = 0; i < 0xffffffff; ++i){} }
#endif /* 0 */

    try
    {
#if defined(_DEBUG) || \
    defined(__SYNSOFT_DBS_DEBUG)
        puts("test.scratch.tstring: " __STLSOFT_COMPILER_LABEL_STRING);
#endif /* debug */

        res = main_(argc, argv);
    }
    catch(std::exception& x)
    {
        pantheios::log_ALERT("Unexpected general error: ", x, ". Application terminating");

        res = EXIT_FAILURE;
    }
    catch(...)
    {
        pantheios::puts(pantheios::emergency, "Unhandled unknown error");

        res = EXIT_FAILURE;
    }

#if defined(_MSC_VER) && \
    defined(_DEBUG)
    _CrtMemDumpAllObjectsSince(&memState);
#endif /* _MSC_VER) && _DEBUG */

    return res;
}
int main(int argc, char** argv)
{
    int             res;

#if defined(_MSC_VER) && \
    defined(_DEBUG)
    _CrtMemState    memState;
#endif /* _MSC_VER && _MSC_VER */

#if defined(_MSC_VER) && \
    defined(_DEBUG)
    _CrtMemCheckpoint(&memState);
#endif /* _MSC_VER && _MSC_VER */

#if 0
    {
        for(size_t i = 0; i < 0xffffffff; ++i) {}
    }
#endif /* 0 */

    try
    {
#if defined(_DEBUG) || \
    defined(__SYNSOFT_DBS_DEBUG)
#endif /* debug */

        res = main_(argc, argv);
    }
    catch(std::exception& x)
    {
        std::cerr << "Unexpected exception: " << x.what() << std::endl;

        res = EXIT_FAILURE;
    }
    catch(...)
    {

        res = EXIT_FAILURE;
    }

#if defined(_MSC_VER) && \
    defined(_DEBUG)
    _CrtMemDumpAllObjectsSince(&memState);
#endif /* _MSC_VER) && _DEBUG */

    return res;
}
示例#16
0
void MemLeakCheck() {
#if (WINDOWSPC>0)
#if _DEBUG
  _CrtMemState memstate_s2, memstate_s3;

   // Store a 2nd memory checkpoint in s2
   _CrtMemCheckpoint( &memstate_s2 );

   if ( _CrtMemDifference( &memstate_s3, &memstate_s1, &memstate_s2 ) ) {
     _CrtMemDumpStatistics( &memstate_s3 );
     _CrtMemDumpAllObjectsSince(&memstate_s1);
   }

  _CrtCheckMemory();
#endif
#endif
}
int main(int argc, char** argv)
{
    int             res;

#if defined(_MSC_VER) && \
    defined(_DEBUG)
    _CrtMemState    memState;
#endif /* _MSC_VER && _MSC_VER */

#if defined(_MSC_VER) && \
    defined(_DEBUG)
    _CrtMemCheckpoint(&memState);
#endif /* _MSC_VER && _MSC_VER */

#if 0
    {
        for(size_t i = 0; i < 0xffffffff; ++i) {}
    }
#endif /* 0 */

    try
    {
        comstl::com_initialiser coinit;

        res = main_(argc, argv);
    }
    catch(std::exception& x)
    {
        std::cerr << "Unexpected general error: " << x.what() << ". Application terminating" << std::endl;

        res = EXIT_FAILURE;
    }
    catch(...)
    {
        std::cerr << "Unhandled unknown error" << std::endl;

        res = EXIT_FAILURE;
    }

#if defined(_MSC_VER) && \
    defined(_DEBUG)
    _CrtMemDumpAllObjectsSince(&memState);
#endif /* _MSC_VER) && _DEBUG */

    return res;
}
int main(int argc, char *argv[])
{
    int             res;

#if defined(_MSC_VER) && \
    defined(_DEBUG)
    _CrtMemState    memState;
#endif /* _MSC_VER && _MSC_VER */

#if defined(_MSC_VER) && \
    defined(_DEBUG)
    _CrtMemCheckpoint(&memState);
#endif /* _MSC_VER && _MSC_VER */

#ifdef STLSOFT_CF_EXCEPTION_SUPPORT
    try
    {
#endif /* STLSOFT_CF_EXCEPTION_SUPPORT */

        res = main_(argc, argv);

#ifdef STLSOFT_CF_EXCEPTION_SUPPORT
    }
    catch(std::exception &x)
    {
                pantheios::log_ALERT(PSTR("Unexpected general error: "), pantheios::exception(x), PSTR(". Application terminating"));

        res = EXIT_FAILURE;
    }
    catch(...)
    {
        pantheios::logputs(pantheios::emergency, PSTR("Unhandled unknown error"));

        res = EXIT_FAILURE;
    }
#endif /* STLSOFT_CF_EXCEPTION_SUPPORT */

#if defined(_MSC_VER) && \
    defined(_DEBUG)
    _CrtMemDumpAllObjectsSince(&memState);
#endif /* _MSC_VER) && _DEBUG */

    return res;
}
示例#19
0
文件: ps.c 项目: endurox-dev/endurox
int main(int argc, char* argv[])
{
    HPSCRIPTVM v;
    PSInteger retval = 0;
#if defined(_MSC_VER) && defined(_DEBUG)
    _CrtSetAllocHook(MemAllocHook);
#endif

    v=ps_open(1024);
    ps_setprintfunc(v,printfunc,errorfunc);

    ps_pushroottable(v);

    psstd_register_bloblib(v);
    psstd_register_iolib(v);
    psstd_register_systemlib(v);
    psstd_register_mathlib(v);
    psstd_register_stringlib(v);
    psstd_register_exutillib(v);

    //aux library
    //sets error handlers
    psstd_seterrorhandlers(v);

    //gets arguments
    switch(getargs(v,argc,argv,&retval))
    {
    case _INTERACTIVE:
        Interactive(v);
        break;
    case _DONE:
    case _ERROR:
    default:
        break;
    }

    ps_close(v);

#if defined(_MSC_VER) && defined(_DEBUG)
    _getch();
    _CrtMemDumpAllObjectsSince( NULL );
#endif
    return retval;
}
示例#20
0
void IOTests::testOutputLeak1()
{
	agent->ExecuteCommandLine("soar stop-phase input") ;
	assertTrue_msg("soar stop-phase input", agent->GetLastCommandLineResult());
	
	agent->ExecuteCommandLine("watch 0") ;
	agent->ExecuteCommandLine("waitsnc --on") ;
	
	agent->LoadProductions(SoarHelper::GetResource("testoutputleak.soar").c_str());
	assertTrue_msg("loadProductions", agent->GetLastCommandLineResult());
	
	/*sml::Identifier* pOutputLink = */agent->GetOutputLink();
	
	kernel->RunAllAgents(1);
	
#ifdef _WIN32
#ifdef _DEBUG
	_CrtMemState memState;
	
	_CrtMemCheckpoint(&memState);
	//_CrtSetBreakAlloc( 3020 );
#endif
#endif
	
	assertTrue(agent->GetNumberCommands() == 1);
	sml::Identifier* pCommand = agent->GetCommand(0) ;
	pCommand->AddStatusComplete();
	
	// need to pass input phase
	kernel->RunAllAgents(2);
	
	assertTrue(kernel->DestroyAgent(agent));
	kernel->Shutdown() ;
	delete kernel ;
	kernel = nullptr;
	
#ifdef _WIN32
#ifdef _DEBUG
	_CrtMemDumpAllObjectsSince(&memState);
#endif
#endif
	
	setUp();
}
int main(int argc, char** argv)
{
    int             res;

#if defined(_MSC_VER) && \
    defined(_DEBUG)
    _CrtMemState    memState;
#endif /* _MSC_VER && _MSC_VER */

#if defined(_MSC_VER) && \
    defined(_DEBUG)
    _CrtMemCheckpoint(&memState);
#endif /* _MSC_VER && _MSC_VER */

    try
    {
#if defined(_DEBUG) || \
    defined(__SYNSOFT_DBS_DEBUG)
        puts("test.scratch.inserter.real: " __STLSOFT_COMPILER_LABEL_STRING);
#endif /* debug */

        res = main_(argc, argv);
    }
    catch(std::exception& x)
    {
        std::cerr << "Unhandled error: " << x.what() << std::endl;

        res = EXIT_FAILURE;
    }
    catch(...)
    {
        std::cerr << "Unhandled unknown error" << std::endl;

        res = EXIT_FAILURE;
    }

#if defined(_MSC_VER) && \
    defined(_DEBUG)
    _CrtMemDumpAllObjectsSince(&memState);
#endif /* _MSC_VER) && _DEBUG */

    return res;
}
示例#22
0
   void
   HeapChecker::Report()
   {
#ifdef _DEBUG
      _CrtMemState m_stateNow;
      _CrtMemCheckpoint( &m_stateNow );

      _CrtMemState m_stateDiff;
      if (_CrtMemDifference(&m_stateDiff, &m_stateStart, &m_stateNow))
      {
         // Memory leaks was found. Report them now.
         _CrtMemDumpAllObjectsSince(&m_stateStart);
         _CrtMemDumpStatistics(&m_stateDiff);

         throw 0; // memory leak

      }
#endif
   }
示例#23
0
int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
	InitCommonControlsEx(&ICC);
	LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_PATH);

	HACCEL hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_APILOG2);
#define MATRIX
#ifdef MATRIX
	TControl::FDefaultBackBrush = CreateSolidBrush(0);
	TControl::FDefaultPen = CreatePen(PS_SOLID, 1, hCol);
	TAppWindow::FWindowClass.hIconSm = LoadIcon(hInstance, (LPCTSTR)IDI_SMALL);
	TAppWindow::FWindowClass.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_APILOG2);
	TControl::FDefaultTextColor = 0x00FF79;
	TGroupBox::FDefaultStyle = 0;

	TCustomGrid::FDefaultTxtColor = mCol;
	TCustomGrid::FDefaultSelTxtColor = 0x00FF79;//0x0FF079;

	TCustomGrid::FDefaultCellsBrush = TControl::FDefaultBackBrush;
	TCustomGrid::FDefaultSelBrush = CreateSolidBrush(hCol);
	TCustomGrid::FDefaultBlurBrush = CreateSolidBrush(0x032C17);
#endif
	HFONT hFont = CreateFontIndirect(&LogFont);
	TProcess * Process = new TProcess(hInstance, 0, nCmdShow, hFont);

    int Result = DefMessageLoop(hAccelTable);
	//DestroyIcon(TAppWindow::FWindowClass.hIconSm);
	//DestroyIcon(TAppWindow::FWindowClass.hIcon);
	DeleteObject(hFont);
#ifdef MATRIX
	DeleteObject(TControl::FDefaultBackBrush);
	DeleteObject(TCustomGrid::FDefaultSelBrush);
	DeleteObject(TControl::FDefaultPen);
#endif

	DestroyAcceleratorTable(hAccelTable);

	_CrtMemDumpAllObjectsSince(0);
    return Result;	
}
示例#24
0
文件: Source.cpp 项目: Enelar/p2pvk
void t_f()
{
  auto test = std::make_shared<rpc>(io);
  test->Run();
//  _CrtSetBreakAlloc(1300);
  for (auto i = 0; i < 2; i++)
  {
    std::this_thread::sleep_for(1s);
    io.run();
  }
  test->Stop();
  // memory allocations take place here
  _CrtMemDumpAllObjectsSince(&s1);
  _CrtMemCheckpoint(&s2);

  if (_CrtMemDifference(&s3, &s1, &s2))
  {
    _CrtMemDumpStatistics(&s3);
  }
}
示例#25
0
int main(int argc, char **argv) {
    ::testing::InitGoogleTest(&argc, argv);

    std::cout << "RapidJSON v" << RAPIDJSON_VERSION_STRING << std::endl;

#ifdef _MSC_VER
    _CrtMemState memoryState = { 0 };
    _CrtMemCheckpoint(&memoryState);
    //_CrtSetBreakAlloc(X);
    //void *testWhetherMemoryLeakDetectionWorks = malloc(1);
#endif

    int ret = RUN_ALL_TESTS();

#ifdef _MSC_VER
    // Current gtest constantly leak 2 blocks at exit
    _CrtMemDumpAllObjectsSince(&memoryState);
#endif
    return ret;
}
示例#26
0
int main(int argc, char** argv)
{
    int             res;

#if defined(_MSC_VER) && \
    defined(_DEBUG)
    _CrtMemState    memState;
#endif /* _MSC_VER && _MSC_VER */

#if defined(_MSC_VER) && \
    defined(_DEBUG)
    _CrtMemCheckpoint(&memState);
#endif /* _MSC_VER && _MSC_VER */

    try
    {
        res = main_(argc, argv);
    }
    catch(std::exception& x)
    {
        fprintf(stderr, "Unhandled error: %s\n", x.what());

        res = EXIT_FAILURE;
    }
    catch(...)
    {
        fprintf(stderr, "Unhandled unknown error\n");

        res = EXIT_FAILURE;
    }

#if defined(_MSC_VER) && \
    defined(_DEBUG)
    _CrtMemDumpAllObjectsSince(&memState);
#endif /* _MSC_VER) && _DEBUG */

    return res;
}
int main(int argc, char** argv)
{
    int             res;

#if defined(_MSC_VER) && \
    defined(_DEBUG)
    _CrtMemState    memState;
#endif /* _MSC_VER && _MSC_VER */

#if defined(_MSC_VER) && \
    defined(_DEBUG)
    _CrtMemCheckpoint(&memState);
#endif /* _MSC_VER && _MSC_VER */

    try
    {
        res = main_(argc, argv);
    }
    catch(std::exception &x)
    {
        pantheios::log_ALERT("Unexpected general error: ", x, ". Application terminating");

        res = EXIT_FAILURE;
    }
    catch(...)
    {
        pantheios::logputs(pantheios::emergency, "Unhandled unknown error");

        res = EXIT_FAILURE;
    }

#if defined(_MSC_VER) && \
    defined(_DEBUG)
    _CrtMemDumpAllObjectsSince(&memState);
#endif /* _MSC_VER) && _DEBUG */

    return res;
}
示例#28
0
// チェックポイントから現在の差分をとって、リークしていればダンプする
void MemoryLeakDetection::dump() const
{
    _CrtMemState stateNow;
    _CrtMemState stateDiff;

    // 現在のチェックポイントとの差分を取得
    _CrtMemCheckpoint(&stateNow);
    _CrtMemDifference(&stateDiff, &mem_state_, &stateNow);

    // ノーマルブロックかクライアントブロックの数が0より大きければ、
    // リークが起きている
    if (stateDiff.lCounts[_NORMAL_BLOCK] > 0 || stateDiff.lCounts[_CLIENT_BLOCK] > 0) {
        if (is_break_) {
            DebugBox("Memory Leak Detected!!");
        }
        DebugTrace("Checkpoint:\n%s(%d)\n", p_file_, line_);
        _CrtMemDumpAllObjectsSince(&mem_state_);
        DebugBreakIf(is_break_);
    }
    else {
        DebugTrace("No Memory Leaks. Checkpoint:\n%s(%d)\n", p_file_, line_);
    }
}
int main(int argc, char **argv)
{
    int             res;
    _CrtMemState    memState;

    _CrtMemCheckpoint(&memState);

    try
    {
        res = main_(argc, argv);
    }
    catch(std::exception& /* x */)
    {
        res = EXIT_FAILURE;
    }
    catch(...)
    {
        res = EXIT_FAILURE;
    }

    _CrtMemDumpAllObjectsSince(&memState);

    return res;
}
HANDEL_EXPORT void xiaMemDumpAllObjectsSince(void)
{
	_CrtMemDumpAllObjectsSince(&before);

	return;
}