41 #include <sys/resource.h>
49 std::stringstream header;
62 TRACE(
"Stack information");
65 void* address_list[20u];
68 unsigned num_addresses = backtrace(address_list,
sizeof(address_list) /
sizeof(
void*));
70 char** symbol_list = backtrace_symbols(address_list, num_addresses);
73 for (
unsigned i = 0; i < num_addresses; i++)
77 TRACE(
"Level " << i <<
": " << symbol_list[i]);
85 TRACE(
"PRINT_MEMORY will now be relative to here");
89 getrusage( RUSAGE_SELF, &rusage );
92 eMemoryAtMarker =
double(rusage.ru_maxrss)/1024.0;
98 TRACE(
"PRINT_MEMORY will now be absolute footprint");
101 eMemoryAtMarker = 0.0;
108 struct rusage rusage;
109 getrusage( RUSAGE_SELF, &rusage );
114 if (fabs(eMemoryAtMarker) < 1e-6)
116 std::cout <<
FormDebugHead() <<
"Total memory footprint: " << memory <<
" Mb" << std::endl << std::flush;
120 std::cout <<
FormDebugHead() <<
"Memory change from marker: " << memory <<
" Mb" << std::endl << std::flush;
std::string FormDebugHead()