MCPcopy Create free account
hub / github.com/apache/impala / ParseSmaps

Method ParseSmaps

be/src/util/mem-info.cc:109–148  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

107}
108
109MappedMemInfo MemInfo::ParseSmaps() {
110 MappedMemInfo result;
111 ifstream smaps("/proc/self/smaps", ios::in);
112 if (!smaps) {
113 LOG_FIRST_N(INFO, 1) << "Could not open smaps";
114 return result;
115 }
116 while (smaps) {
117 string line;
118 getline(smaps, line);
119 if (line.empty()) continue;
120 if (isdigit(line[0]) || (line[0] >= 'a' && line[0] <= 'f')) {
121 // Line is the start of a new mapping, of form:
122 // 561ceff9c000-561ceffa1000 rw-p 00000000 00:00 0
123 // We distinguish this case by checking for lower-case hex digits.
124 ++result.num_maps;
125 continue;
126 }
127 // Line is in the form of <Name>:<spaces><value>, e.g.:
128 // Size: 1084 kB
129 // VmFlags: rd ex mr mw me dw
130 size_t colon_pos = line.find(':');
131 if (colon_pos == string::npos) continue;
132 string name = line.substr(0, colon_pos);
133 size_t non_space_after_colon_pos = line.find_first_not_of(' ', colon_pos + 1);
134 if (non_space_after_colon_pos == string::npos) continue;
135 // From the first non-space after the colon through the end of the string.
136 string value = line.substr(non_space_after_colon_pos);
137
138 // Use atol() to parse the value, ignoring " kB" suffix.
139 if (name == "Size") {
140 result.size_kb += atol(value.c_str());
141 } else if (name == "Rss") {
142 result.rss_kb += atol(value.c_str());
143 } else if (name == "AnonHugePages") {
144 result.anon_huge_pages_kb += atol(value.c_str());
145 }
146 }
147 return result;
148}
149
150ThpConfig MemInfo::ParseThpConfig() {
151 ThpConfig result;

Callers

nothing calls this directly

Calls 4

substrMethod · 0.80
find_first_not_ofMethod · 0.80
emptyMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected