12 #include <mach/task.h> 13 #include <mach/mach_init.h> 14 #include <malloc/malloc.h> 30 #if defined(__linux__) && defined(__GLIBC__) 32 struct mallinfo m = mallinfo();
33 out <<
" non-mmapped space allocated from system: " << m.arena <<
"\n";
34 out <<
" number of free chunks: " << m.ordblks <<
"\n";
35 out <<
" number of fastbin blocks: " << m.smblks <<
"\n";
36 out <<
" number of mmapped regions: " << m.hblks <<
"\n";
37 out <<
" space in mmapped regions: " << m.hblkhd <<
"\n";
38 out <<
" maximum total allocated space: " << m.usmblks <<
"\n";
39 out <<
" space available in freed fastbin blocks: " << m.fsmblks <<
"\n";
40 out <<
" total allocated space: " << m.uordblks <<
"\n";
41 out <<
" total free space: " << m.fordblks <<
"\n";
46 PROCESS_MEMORY_COUNTERS pmc;
47 if(GetProcessMemoryInfo(GetCurrentProcess(), &pmc,
sizeof(pmc)))
49 out <<
" PeakWorkingSetSize: " << pmc.PeakWorkingSetSize <<
"\n";
50 out <<
" WorkingSetSize: " << pmc.WorkingSetSize <<
"\n";
57 struct task_basic_info t_info;
58 mach_msg_type_number_t t_info_count = TASK_BASIC_INFO_COUNT;
60 current_task(), TASK_BASIC_INFO, (task_info_t)&t_info, &t_info_count);
61 out <<
" virtual size: " 62 <<
static_cast<double>(t_info.virtual_size)/1000000 <<
"m\n";
64 malloc_statistics_t t;
65 malloc_zone_statistics(NULL, &t);
66 out <<
" max_size_in_use: " 67 <<
static_cast<double>(t.max_size_in_use)/1000000 <<
"m\n";
68 out <<
" size_allocated: " 69 <<
static_cast<double>(t.size_allocated)/1000000 <<
"m\n";
void memory_info(std::ostream &out)