| 193 | } |
| 194 | |
| 195 | void MemTracker::TrackersToPb(MemTrackerPB* pb) { |
| 196 | CHECK(pb); |
| 197 | stack<std::pair<shared_ptr<MemTracker>, MemTrackerPB*>> to_process; |
| 198 | to_process.emplace(std::make_pair(GetRootTracker(), pb)); |
| 199 | while (!to_process.empty()) { |
| 200 | auto tracker_and_pb = std::move(to_process.top()); |
| 201 | to_process.pop(); |
| 202 | auto& tracker = tracker_and_pb.first; |
| 203 | auto* tracker_pb = tracker_and_pb.second; |
| 204 | tracker_pb->set_id(tracker->id()); |
| 205 | if (tracker->parent()) { |
| 206 | tracker_pb->set_parent_id(tracker->parent()->id()); |
| 207 | } |
| 208 | tracker_pb->set_limit(tracker->limit()); |
| 209 | tracker_pb->set_current_consumption(tracker->consumption()); |
| 210 | tracker_pb->set_peak_consumption(tracker->peak_consumption()); |
| 211 | { |
| 212 | MutexLock l(tracker->child_trackers_lock_); |
| 213 | for (const auto& child_weak : tracker->child_trackers_) { |
| 214 | shared_ptr<MemTracker> child = child_weak.lock(); |
| 215 | if (child) { |
| 216 | auto* child_pb = tracker_pb->add_child_trackers(); |
| 217 | to_process.emplace(std::make_pair(std::move(child), child_pb)); |
| 218 | } |
| 219 | } |
| 220 | } |
| 221 | } |
| 222 | } |
| 223 | |
| 224 | void MemTracker::Consume(int64_t bytes) { |
| 225 | if (bytes < 0) { |
nothing calls this directly
no test coverage detected