12 #include <mach/task.h>
13 #include <mach/mach_init.h>
14 #include <malloc/malloc.h>
22 #include <util/pragma_push.def>
24 #pragma warning(disable:4668)
26 #pragma warning(disable : 5039)
31 #include <util/pragma_pop.def>
38 #if defined(__linux__) && defined(__GLIBC__)
40 struct mallinfo m = mallinfo();
41 out <<
" non-mmapped space allocated from system: " << m.arena <<
"\n";
42 out <<
" number of free chunks: " << m.ordblks <<
"\n";
43 out <<
" number of fastbin blocks: " << m.smblks <<
"\n";
44 out <<
" number of mmapped regions: " << m.hblks <<
"\n";
45 out <<
" space in mmapped regions: " << m.hblkhd <<
"\n";
46 out <<
" maximum total allocated space: " << m.usmblks <<
"\n";
47 out <<
" space available in freed fastbin blocks: " << m.fsmblks <<
"\n";
48 out <<
" total allocated space: " << m.uordblks <<
"\n";
49 out <<
" total free space: " << m.fordblks <<
"\n";
51 PROCESS_MEMORY_COUNTERS pmc;
52 if(GetProcessMemoryInfo(GetCurrentProcess(), &pmc,
sizeof(pmc)))
54 out <<
" peak working set size [bytes]: " << pmc.PeakWorkingSetSize
56 out <<
" current working set size [bytes]: " << pmc.WorkingSetSize <<
"\n";
58 #elif defined(__APPLE__)
60 struct task_basic_info t_info;
61 mach_msg_type_number_t t_info_count = TASK_BASIC_INFO_COUNT;
63 current_task(), TASK_BASIC_INFO, (task_info_t)&t_info, &t_info_count);
64 out <<
" virtual size: "
65 <<
static_cast<double>(t_info.virtual_size)/1000000 <<
"m\n";
67 malloc_statistics_t t;
68 malloc_zone_statistics(NULL, &t);
69 out <<
" max_size_in_use: "
70 <<
static_cast<double>(t.max_size_in_use)/1000000 <<
"m\n";
71 out <<
" size_allocated: "
72 <<
static_cast<double>(t.size_allocated)/1000000 <<
"m\n";