m_maxAllocationTraceIndex.index = 0;
totalAllocated = 0;
totalAllocations = 0;
+ totalTemporary = 0;
peak = 0;
leaked = 0;
allocations.clear();
sizeHistogram.clear();
+ uint64_t lastAllocationPtr = 0;
while (reader.getLine(in)) {
if (reader.mode() == 's') {
if (leaked > peak) {
peak = leaked;
}
+ lastAllocationPtr = ptr;
handleAllocation();
if (printHistogram) {
++sizeHistogram[size];
allocation.leaked -= info.size;
}
leaked -= info.size;
+ if (lastAllocationPtr == ptr) {
+ ++allocation.temporary;
+ ++totalTemporary;
+ }
+ lastAllocationPtr = 0;
} else if (reader.mode() == '#') {
// comment or empty line
continue;
merged.allocations += allocation.allocations;
merged.leaked += allocation.leaked;
merged.peak += allocation.peak;
+ merged.temporary += allocation.temporary;
}
}
return ret;
"Print backtraces to top allocators, sorted by peak consumption.")
("print-allocators,a", po::value<bool>()->default_value(true)->implicit_value(true),
"Print backtraces to top allocators, sorted by number of calls to allocation functions.")
+ ("print-temporary,T", po::value<bool>()->default_value(true)->implicit_value(true),
+ "Print backtraces to top allocators, sorted by number of temporary allocations.")
("print-leaks,l", po::value<bool>()->default_value(false)->implicit_value(true),
"Print backtraces to leaked memory allocations.")
("print-overall-allocated,o", po::value<bool>()->default_value(false)->implicit_value(true),
const bool printOverallAlloc = vm["print-overall-allocated"].as<bool>();
const bool printPeaks = vm["print-peaks"].as<bool>();
const bool printAllocs = vm["print-allocators"].as<bool>();
+ const bool printTemporary = vm["print-temporary"].as<bool>();
cout << "reading file \"" << inputFile << "\" - please wait, this might take some time..." << endl;
if (!data.read(inputFile)) {
cout << endl;
}
+ if (printTemporary) {
+ // sort by amount of temporary allocations
+ cout << "MOST TEMPORARY ALLOCATIONS\n";
+ data.printAllocations(&AllocationData::temporary, [] (const AllocationData& data) {
+ cout << data.temporary << " temporary allocations of " << data.allocations << " allocations in total ("
+ << setprecision(2) << (float(data.temporary) * 100.f / data.allocations) << "%) from\n";
+ }, [] (const AllocationData& data) {
+ cout << data.temporary << " temporary allocations of " << data.allocations << " allocations in total ("
+ << setprecision(2) << (float(data.temporary) * 100.f / data.allocations) << "%) from:\n";
+ });
+ cout << endl;
+ }
+
const double totalTimeS = 0.001 * data.totalTime;
cout << "total runtime: " << fixed << totalTimeS << "s.\n"
<< "bytes allocated in total (ignoring deallocations): " << formatBytes(data.totalAllocated)
<< " (" << formatBytes(data.totalAllocated / totalTimeS) << "/s)" << '\n'
<< "calls to allocation functions: " << data.totalAllocations
<< " (" << size_t(data.totalAllocations / totalTimeS) << "/s)\n"
+ << "temporary memory allocations: " << data.totalTemporary
+ << " (" << size_t(data.totalTemporary / totalTimeS) << "/s)\n"
<< "peak heap memory consumption: " << formatBytes(data.peak) << '\n'
<< "total memory leaked: " << formatBytes(data.leaked) << '\n';