16 # include <util/pragma_push.def>
18 # pragma warning(disable : 4668)
20 # pragma warning(disable : 5039)
23 # include <util/pragma_pop.def>
29 #elif defined(__APPLE__)
30 # include <mach/mach_init.h>
31 # include <mach/task.h>
32 # include <malloc/malloc.h>
34 # include <sys/resource.h>
43 struct mallinfo m = mallinfo();
44 out <<
" non-mmapped space allocated from system: " << m.arena <<
"\n";
45 out <<
" number of free chunks: " << m.ordblks <<
"\n";
46 out <<
" number of fastbin blocks: " << m.smblks <<
"\n";
47 out <<
" number of mmapped regions: " << m.hblks <<
"\n";
48 out <<
" space in mmapped regions: " << m.hblkhd <<
"\n";
49 out <<
" maximum total allocated space: " << m.usmblks <<
"\n";
50 out <<
" space available in freed fastbin blocks: " << m.fsmblks <<
"\n";
51 out <<
" total allocated space: " << m.uordblks <<
"\n";
52 out <<
" total free space: " << m.fordblks <<
"\n";
54 PROCESS_MEMORY_COUNTERS pmc;
55 if(GetProcessMemoryInfo(GetCurrentProcess(), &pmc,
sizeof(pmc)))
57 out <<
" peak working set size [bytes]: " << pmc.PeakWorkingSetSize
59 out <<
" current working set size [bytes]: " << pmc.WorkingSetSize <<
"\n";
61 #elif defined(__APPLE__)
63 struct task_basic_info t_info;
64 mach_msg_type_number_t t_info_count = TASK_BASIC_INFO_COUNT;
66 current_task(), TASK_BASIC_INFO, (task_info_t)&t_info, &t_info_count);
67 out <<
" virtual size: "
68 <<
static_cast<double>(t_info.virtual_size)/1000000 <<
"m\n";
70 malloc_statistics_t t;
71 malloc_zone_statistics(NULL, &t);
72 out <<
" max_size_in_use: "
73 <<
static_cast<double>(t.max_size_in_use)/1000000 <<
"m\n";
74 out <<
" size_allocated: "
75 <<
static_cast<double>(t.size_allocated)/1000000 <<
"m\n";
78 struct rusage r_usage;
79 int result = getrusage(RUSAGE_SELF, &r_usage);
81 out <<
" maximum resident set size [bytes]: " << r_usage.ru_maxrss <<
'\n';
void memory_info(std::ostream &out)
#define CHECK_RETURN(CONDITION)