| 230 | } |
| 231 | |
| 232 | std::tuple<uint64_t, std::unordered_map<MemoryType, uint64_t>> |
| 233 | MemoryTracker::get_counts() const { |
| 234 | std::lock_guard<std::mutex> lg(mutex_); |
| 235 | |
| 236 | auto total = total_counter_.load(std::memory_order_relaxed); |
| 237 | std::unordered_map<MemoryType, uint64_t> by_type; |
| 238 | std::vector<MemoryType> to_del; |
| 239 | for (auto& [mem_type, resource] : resources_) { |
| 240 | by_type[mem_type] = resource->get_count(); |
| 241 | } |
| 242 | |
| 243 | return {total, by_type}; |
| 244 | } |
| 245 | |
| 246 | uint64_t MemoryTracker::generate_id() { |
| 247 | static std::atomic<uint64_t> curr_id{0}; |