56 {
58
59#if ( defined(__MACH__) && defined(__clang__) && defined(__x86_64__) ) || \
60 ( defined(__MACH__) && defined(__GNUC__) && __GNUC__>=4 && __GNUC_MINOR__>=7 ) || \
61 defined(__linux__) || defined(_AIX)
62
63
64
65 ifstream stat_stream("/proc/self/stat", ios_base::in);
66
67
68
69 string pid, comm, state, ppid, pgrp,
session, tty_nr;
70 string tpgid, flags, minflt, cminflt, majflt, cmajflt;
71 string utime, stime, cutime, cstime, priority, nice;
72 string O, itrealvalue, starttime;
73
74
75
76 unsigned long vsize;
77 long rss;
78
79 stat_stream >> pid >> comm >> state >> ppid >> pgrp >>
session >> tty_nr
80 >> tpgid >> flags >> minflt >> cminflt >> majflt >> cmajflt >> utime
81 >> stime >> cutime >> cstime >> priority >> nice >> O >> itrealvalue
82 >> starttime >> vsize >> rss;
83
84 stat_stream.close();
85
86 long page_size_kb = sysconf(_SC_PAGE_SIZE) / 1024;
87 output.
vmz = vsize / 1024.0;
88 output.
mem = rss * page_size_kb;
89#endif
90
91 return output;
92 }