int Test() { VLDSetOptions(VLD_OPT_TRACE_INTERNAL_FRAMES | VLD_OPT_SKIP_CRTSTARTUP_LEAKS, 256, 64); void* m = malloc(50); // 8 char* n = new char[60]; // 9 memset(s_m, '1', 10); memset(s_n, '2', 20); memset(g_m, '3', 30); memset(g_n, '4', 40); memset(m, '5', 50); memset(n, '6', 60); // std libary dynamically initializes the objects "cout" and "cerr", which // produce false positive leaks in Release_StaticCrt because we doesn't have // debug CRT allocation header. std::cout << "Test: cout"; //std::cerr << "Test: cerr"; // At this point VLDGetLeaksCount() and VLDReportLeaks() should report 9 leaks // including a leak for ml which has not been freed yet. ml will be freed after // _tmain exits but before VLDReportLeaks() is called internally by VLD and // therefore correctly report 8 leaks. int leaks = VLDGetLeaksCount(); VLDReportLeaks(); // at this point should report 9 leaks; return leaks; }
int Test() { VLDSetOptions(VLD_OPT_TRACE_INTERNAL_FRAMES | VLD_OPT_SKIP_CRTSTARTUP_LEAKS, 256, 64); void* m = malloc(50); // 8 char* n = new char[60]; // 9 memset(s_m, '1', 10); memset(s_n, '2', 20); memset(g_m, '3', 30); memset(g_n, '4', 40); memset(m, '5', 50); memset(n, '6', 60); // At this point VLDGetLeaksCount() and VLDReportLeaks() should report 9 leaks // including a leak for ml which has not been freed yet. ml will be freed after // _tmain exits but before VLDReportLeaks() is called internally by VLD and // therefore correctly report 8 leaks. // VLDReportLeaks(); // at this point should report 9 leaks; return VLDGetLeaksCount(); }