int main(int argc, char* argv[]) { _CrtMemState s1,s2,s3; int r; if(argc == 2) { return RUN_TEST_BY_CATALOG(argv[1], &out); } else if(argc >= 3 ) { char name[512]; strcpy(name, argv[1]); strcat(name, "_"); strcat(name, argv[2]); return RUN_TEST_BY_NAME(name, &out); } RUN_ALL_TESTS(&out); _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE); _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDOUT); _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE ); _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDOUT ); _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE ); _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDOUT ); _CrtMemCheckpoint( &s1 ); malloc(3); r = RUN_ALL_TESTS(&out); _CrtMemCheckpoint( &s2 ); if ( _CrtMemDifference( &s3, &s1, &s2) ) { _CrtMemDumpStatistics( &s3 ); } return r; }
int main() { char buf[50]; char buf1[50]; struct sockaddr_in sin; SafeSock ssock; IpVerify* userverify; set_mySubSystem( "COLLECTOR", SUBSYSTEM_TYPE_COLLECTOR ); config(); #ifdef WIN32 _CrtMemCheckpoint( &s1 ); #endif userverify = new IpVerify(); userverify->Init(); buf[0] = '\0'; while( 1 ) { printf("Enter test:\n"); scanf("%s",buf); if ( strncmp(buf,"exit",4) == 0 ) break; if ( strncmp(buf,"reinit",6) == 0 ) { config(); userverify->Init(); continue; } printf("Verifying %s ... ",buf); sprintf(buf1,"<%s:1970>",buf); string_to_sin(buf1,&sin); if ( userverify->Verify(WRITE,&sin) == TRUE ) printf("ALLOW\n"); else printf("DENY\n"); } delete userverify; #ifdef WIN32 _CrtMemCheckpoint( &s2 ); // _CrtMemDumpAllObjectsSince( &s1 ); _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE); _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDOUT); _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE); _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDOUT); _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE); _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDOUT); if ( _CrtMemDifference( &s3, &s1, &s2 ) ) _CrtMemDumpStatistics( &s3 ); // _CrtDumpMemoryLeaks(); // report any memory leaks on Win32 #endif return TRUE; }
bool Test::PerformTest() { printf("\nTEST: %s ...\n", test_name); bool result; _CrtMemState s1, s2, s3; _CrtMemCheckpoint(&s1); result = DoTest(); _CrtMemCheckpoint(&s2); if (_CrtMemDifference(&s3, &s1, &s2)) { result = false; printf("leak detected\n"); _CrtMemDumpStatistics(&s3); } if (result) { printf("RESULT: passed\n"); } else { printf("RESULT: error\n"); } return result; }
HANDEL_EXPORT void xiaMemCheckpoint(int pass) { switch (pass) { case XIA_BEFORE: _CrtMemCheckpoint(&before); break; case XIA_AFTER: _CrtMemCheckpoint(&after); #pragma warning(disable : 4127) _RPT0(_CRT_WARN, "****Dumping Memory Changes Between Checkpoints****\n"); #pragma warning(default : 4127) #pragma warning(disable : 4127) if (!_CrtMemDifference(&difference, &before, &after)) { #pragma warning(default : 4127) _CrtMemDumpStatistics(&difference); } break; } return; }
int main(int argc, char *argv[]) { _CrtMemState _ms; _CrtMemCheckpoint(&_ms); //Мы записываем в специальную структуру //начальное (текущее на момент входа в main) состояние памяти (_CrtMemCheckpoint), //а перед завершением работы приложения выводим все оставшиеся объекты //в памяти (_CrtMemDumpAllObjectsSince), созданные после момента _ms — они-то и есть «утечки». QCoreApplication a(argc, argv); QTest::qExec(new test, argc, argv); Set<string> s1,s2; string file1,file2,buf; ifstream fin; // char dir[255]; // GetCurrentDirectoryA(255, dir); //cout << dir << endl; cout<<"Enter 1 name of file: "; cin>>file1; fin.open(file1); if(fin.is_open()){ while(fin>>buf) s1|=buf; } else perror("File 1 doesn't open");
void debug_init() { /* Send all reports to STDOUT */ _CrtSetReportMode( _CRT_WARN, _CRTDBG_MODE_FILE ); _CrtSetReportFile( _CRT_WARN, _CRTDBG_FILE_STDOUT ); _CrtSetReportMode( _CRT_ERROR, _CRTDBG_MODE_FILE ); _CrtSetReportFile( _CRT_ERROR, _CRTDBG_FILE_STDOUT ); _CrtSetReportMode( _CRT_ASSERT, _CRTDBG_MODE_FILE ); _CrtSetReportFile( _CRT_ASSERT, _CRTDBG_FILE_STDOUT ); _CrtMemCheckpoint( &s1 ); /* * Set the debug-heap flag so that freed blocks are kept on the * linked list, to catch any inadvertent use of freed memory */ SET_CRT_DEBUG_FIELD( _CRTDBG_DELAY_FREE_MEM_DF ); /* * Set the debug-heap flag so that memory leaks are reported when * the process terminates. Then, exit. */ SET_CRT_DEBUG_FIELD( _CRTDBG_LEAK_CHECK_DF ); }
int CBasicMemoryLeakDetection::compareMemoryState(void) { int MemoryLeak = 0; #ifdef _ENABLE_MEMORY_LEAK_DETECTION_ _CrtMemState CurrentMemoryState; _CrtMemState MemoryDifference; _CrtMemCheckpoint(&CurrentMemoryState); _CrtMemDifference(&MemoryDifference, &mMemoryState, &CurrentMemoryState); MemoryLeak += static_cast<int>(MemoryDifference.lSizes[_NORMAL_BLOCK]); MemoryLeak += static_cast<int>(MemoryDifference.lSizes[_IGNORE_BLOCK]); MemoryLeak += static_cast<int>(MemoryDifference.lSizes[_CLIENT_BLOCK]); /* if (MemoryLeak) { std::cout << "Detected Memory Leak for _NORMAL_BLOCK: " << std::dec << MemoryDifference.lSizes[_NORMAL_BLOCK] << std::endl; std::cout << "Detected Memory Leak for _IGNORE_BLOCK: " << std::dec << MemoryDifference.lSizes[_IGNORE_BLOCK] << std::endl; std::cout << "Detected Memory Leak for _CLIENT_BLOCK: " << std::dec << MemoryDifference.lSizes[_CLIENT_BLOCK] << std::endl; } */ #endif // _ENABLE_MEMORY_LEAK_DETECTION_ mWasMemoryChecked = true; return MemoryLeak; }
void EndCrtCheck() { _CrtMemState state_end; _CrtMemState state_diff; _CrtMemCheckpoint(&state_end); if (_CrtMemDifference(&state_diff, &g_state_begin, &state_end)) _CrtMemDumpStatistics(&state_diff); }
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 }
void debug_check() { _CrtMemState *temp; OutputHeading("Checking memory..."); if (ss1 == NULL) { debug_init(); ss1 = &s1; ss2 = &s2; } _CrtCheckMemory(); /* _CrtMemDumpAllObjectsSince( NULL ); */ _CrtMemCheckpoint( &s2 ); if ( _CrtMemDifference( &s3, &s1, &s2 ) ) _CrtMemDumpStatistics( &s3 ); /* _CrtDumpMemoryLeaks(); */ /* * swap the snapshots around */ temp = ss1; ss1 = ss2; ss2 = temp; }
void HeapChecker::Reset() { #ifdef _DEBUG _CrtMemCheckpoint( &m_stateStart ); #endif }
void DebugMemCheckStartPoint(void) { #ifdef FORTIFY Fortify_EnterScope(); #else _CrtMemCheckpoint(&oldState); #endif }
bool LeakDetector::IsLeakDetected() { _CrtMemState newState; _CrtMemState temp; _CrtMemCheckpoint(&newState); return !!_CrtMemDifference(&temp, &originalMemoryState, &newState); }
void MemCheckPoint() { #if (WINDOWSPC>0) #if _DEBUG _CrtMemCheckpoint( &memstate_s1 ); #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 { #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; }
EWXWEXPORT(void,ELJApp_InitializeC)(wxClosure* closure,int _argc,char** _argv) { wxHANDLE wxhInstance = GetModuleHandle(NULL); /* check memory leaks with visual C++ */ #if (defined(__WXDEBUG__) && defined(_MSC_VER)) _CrtMemState memStart,memEnd,memDif; _CrtMemCheckpoint( &memStart ); _CrtSetReportMode( _CRT_WARN, _CRTDBG_MODE_FILE ); _CrtSetReportFile( _CRT_WARN, _CRTDBG_FILE_STDOUT ); _CrtSetReportMode( _CRT_ERROR, _CRTDBG_MODE_FILE ); _CrtSetReportFile( _CRT_ERROR, _CRTDBG_FILE_STDOUT ); _CrtSetReportMode( _CRT_ASSERT, _CRTDBG_MODE_FILE ); _CrtSetReportFile( _CRT_ASSERT, _CRTDBG_FILE_STDOUT ); #endif initClosure = closure; APPTerminating = 0; wxEntry(wxhInstance, NULL, (_argc > 0 ? _argv[0] : NULL), SW_SHOWNORMAL); APPTerminating = 1; /* wxPendingEvents is deleted but not set to NULL -> disaster when restarted from an interpreter */ #if !defined(WXMAKINGDLL) && !defined(WXUSINGDLL) wxPendingEvents = NULL; #endif #if defined(wxUSE_ODBC) && (wxUSE_ODBC != 0) wxDbCloseConnections(); #endif /* check memory leaks with visual C++ */ #if (defined(__WXDEBUG__) && defined(_MSC_VER)) _CrtMemCheckpoint( &memEnd ); if (_CrtMemDifference( &memDif, &memStart, &memEnd) && (memDif.lCounts[_NORMAL_BLOCK]>=-2 && memDif.lCounts[_NORMAL_BLOCK] <= 0)) { _RPT0(_CRT_WARN,"\n** memory leak detected (**\n" ); _CrtMemDumpStatistics(&memDif); /* _CrtMemDumpAllObjectsSince(&memStart); */ _RPT0(_CRT_WARN,"** memory leak report done **\n\n" ); } #endif }
void main() { //PrepareLogFunction(io); _CrtMemCheckpoint(&s1); t_f(); _CrtMemDumpAllObjectsSince(&s1); Log("Exit sequence initiated"); std::cout << std::endl << "== INITIATE EXIT SEQUENCE." << std::endl; }
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { #ifdef _DEBUG // #define new DEBUG_NEW _CrtMemState s1,s2,s3; _CrtMemCheckpoint( &s1 ); #endif //srand( (unsigned)time( NULL ) ); setlocale( LC_CTYPE, "" ); setlocale( LC_COLLATE, "" ); KRKAL=new CKrkal; if(KRKAL->Init(hInstance)) { KRKAL->SetTimes(33,33); KRKAL->SetTimeOuts(300,600); KRKAL->Run(); } delete KRKAL; #ifdef _DEBUG _CrtMemCheckpoint( &s2 ); if ( _CrtMemDifference( &s3, &s1, &s2 ) ) { // _CrtDumpMemoryLeaks(); MessageBox( NULL, "Detected memory leak!", "KRKAL", MB_ICONERROR|MB_OK ); } #endif return 1; }
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; }
void NDInstanceBase::EndStaticsMem() { _CrtMemState s2, s3; _CrtMemCheckpoint( &s2 ); if ( _CrtMemDifference( &s3, &m_s1, &s2 ) ) { _CrtSetReportHook( NDReportHook ) ; _CrtMemDumpStatistics( &s3 ); _CrtSetReportHook( NULL ) ; } }
void memStats() { #if (defined(WIN32) && defined(CHECK_LEAKS)) _CrtSetReportMode( _CRT_WARN, _CRTDBG_MODE_FILE ); _CrtSetReportFile( _CRT_WARN, _CRTDBG_FILE_STDERR ); _CrtMemState memsnap; _CrtMemCheckpoint(&memsnap); _CrtMemDumpStatistics(&memsnap); #endif }
void BeginCrtCheck() { static bool ok_init = false; if (!ok_init) { ok_init = true; InitCrtCheck(); } else NULL; _CrtMemCheckpoint(&g_state_begin); }
void DebugMemCheckEndPoint(void) { #ifdef FORTIFY Fortify_LeaveScope(); #else _CrtMemCheckpoint(&newState); _CrtMemDifference(&stateDiff, &oldState, &newState); _CrtMemDumpStatistics(&stateDiff); #endif }
void CBasicMemoryLeakDetection::resetMemoryState(void) { #ifdef _ENABLE_MEMORY_LEAK_DETECTION_ _CrtMemCheckpoint(&mMemoryState); #endif // _ENABLE_MEMORY_LEAK_DETECTION_ mWasMemoryChecked = false; return; }
void sipXtapiTestSuite::setUp() { printf("sipXtapiTestSuite::setUp line: %d\n", __LINE__); #ifdef _WIN32 #ifdef SIPX_TEST_FOR_MEMORY_LEAKS _CrtSetReportMode( _CRT_WARN, _CRTDBG_MODE_FILE); _CrtSetReportFile( _CRT_WARN, _CRTDBG_FILE_STDOUT); _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_CHECK_ALWAYS_DF) ; _CrtMemCheckpoint( &msBeforeTest ); #endif #endif suiteLock.acquire(); sipxConfigSetLogLevel(LOG_LEVEL_DEBUG); sipxConfigSetLogFile("sipXtapiTests.txt") ; if (g_hInst == NULL) { sipxInitialize(&g_hInst, 8000, 8000, 8001, 8050, 32, HINST_ADDRESS, "127.0.0.1", false, NULL, NULL, NULL, true, INTERNAL_SAMPLE_RATE, DEVICE_SAMPLE_RATE) ; sipxConfigSetConnectionIdleTimeout(g_hInst, 7) ; } if (g_hInst2 == NULL) { sipxInitialize(&g_hInst2, 9100, 9100, 9101, 9050, 32, HINST2_ADDRESS, "127.0.0.1", false, NULL, NULL, NULL, true, INTERNAL_SAMPLE_RATE, DEVICE_SAMPLE_RATE) ; sipxConfigSetConnectionIdleTimeout(g_hInst2, 7) ; } if (g_hInst3 == NULL) { sipxInitialize(&g_hInst3, 10000, 10000, 10001, 10050, 32, HINST3_ADDRESS, "127.0.0.1", false, NULL, NULL, NULL, true, INTERNAL_SAMPLE_RATE, DEVICE_SAMPLE_RATE) ; sipxConfigSetConnectionIdleTimeout(g_hInst3, 7) ; } if (g_hInst4 == NULL) { sipxInitialize(&g_hInst4, 12070, 12070, 12071, 12050, 32, HINST4_ADDRESS, "127.0.0.1, false, NULL, NULL, NULL, true, INTERNAL_SAMPLE_RATE, DEVICE_SAMPLE_RATE") ; sipxConfigSetConnectionIdleTimeout(g_hInst4, 7) ; } /* if (g_hInst5 == NULL) { sipxInitialize(&g_hInst5, 5060, 5060, 5061, 13000, 32) ; } */ #ifdef PURIFY PurifyClearLeaks(); #endif suiteLock.release(); printf("sipXtapiTestSuite::setUp line: %d\n", __LINE__); }
int main() { int i = 0; _CrtMemState memory; // C/C++ runtime memory management state storage while (i < 1000) { f(i++); // dump memory management state _CrtMemCheckpoint(&memory); _CrtMemDumpStatistics(&memory); } _CrtDumpMemoryLeaks(); // check if there were memory leaks return 0; }
void LeakDetectorImpl::checkPointImpl() { if (0 == _cpIndex) resetImpl(); _CrtMemCheckpoint(&_state[_cpIndex]); if (1 == _cpIndex++) { _hasLeaks = (0 != _CrtMemDifference(&_state[2], &_state[0], &_state[1])); _cpIndex = 0; } }
int main__(int argc, char** argv) { _CrtMemState memState; _CrtMemCheckpoint(&memState); int r = main_(argc, argv); _CrtMemDumpAllObjectsSince(&memState); return r; }
int main() { #if MG_PLATFORM_WINDOWS && MUGGLE_DEBUG _CrtMemState s1, s2, s3; _CrtMemCheckpoint(&s1); #endif TestFunction(); TestPerformance(); #if MG_PLATFORM_WINDOWS && MUGGLE_DEBUG _CrtMemCheckpoint(&s2); if (_CrtMemDifference(&s3, &s1, &s2)) { _CrtMemDumpStatistics(&s3); } _CrtDumpMemoryLeaks(); #endif return 0; }
virtual void OnTestEnd(const TestInfo& test_info) { if (test_info.result()->Passed()) { _CrtMemState stateNow, stateDiff; _CrtMemCheckpoint(&stateNow); int diffResult = _CrtMemDifference(&stateDiff, &memState_, &stateNow); if (diffResult) { FAIL() << "Memory leak of " << stateDiff.lSizes[1] << " byte(s) detected."; } } }