34 #include <mach/mach_init.h>
35 #include <mach/shared_region.h>
36 #include <mach/task.h>
60 if (gethostname(host,
sizeof host) == -1)
61 warn(
"could not get host name!");
73 procInfo(
const char *filename,
const char *target)
80 FILE *
fp = fopen(filename,
"r");
82 while (fp && !feof(fp) && !done) {
83 if (fgets(line, 80, fp)) {
85 snprintf(format,
sizeof(format),
"%s %%ld", target);
86 sscanf(line, format, &usage);
105 struct task_basic_info t_info;
106 mach_msg_type_number_t t_info_count = TASK_BASIC_INFO_COUNT;
108 if (KERN_SUCCESS != task_info(mach_task_self(),
109 TASK_BASIC_INFO, (task_info_t)&t_info,
117 return (t_info.virtual_size - SHARED_REGION_SIZE) / 1024;
120 return procInfo(
"/proc/self/status",
"VmSize:");
uint64_t memUsage()
Determine the simulator process' total virtual memory usage.
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,16,32,64}_t.
uint64_t procInfo(const char *filename, const char *target)
bool startswith(const char *s, const char *prefix)
Return true if 's' starts with the prefix string 'prefix'.
Bitfield< 31, 29 > format