diff options
Diffstat (limited to 'lldb/source/Utility/ConstString.cpp')
| -rw-r--r-- | lldb/source/Utility/ConstString.cpp | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/lldb/source/Utility/ConstString.cpp b/lldb/source/Utility/ConstString.cpp index e5e1b2387e64..142c335ddbbe 100644 --- a/lldb/source/Utility/ConstString.cpp +++ b/lldb/source/Utility/ConstString.cpp @@ -159,16 +159,15 @@ public: return nullptr; } - // Return the size in bytes that this object and any items in its collection - // of uniqued strings + data count values takes in memory. - size_t MemorySize() const { - size_t mem_size = sizeof(Pool); + ConstString::MemoryStats GetMemoryStats() const { + ConstString::MemoryStats stats; for (const auto &pool : m_string_pools) { llvm::sys::SmartScopedReader<false> rlock(pool.m_mutex); - for (const auto &entry : pool.m_string_map) - mem_size += sizeof(StringPoolEntryType) + entry.getKey().size(); + const Allocator &alloc = pool.m_string_map.getAllocator(); + stats.bytes_total += alloc.getTotalMemory(); + stats.bytes_used += alloc.getBytesAllocated(); } - return mem_size; + return stats; } protected: @@ -327,9 +326,8 @@ void ConstString::SetTrimmedCStringWithLength(const char *cstr, m_string = StringPool().GetConstTrimmedCStringWithLength(cstr, cstr_len); } -size_t ConstString::StaticMemorySize() { - // Get the size of the static string pool - return StringPool().MemorySize(); +ConstString::MemoryStats ConstString::GetMemoryStats() { + return StringPool().GetMemoryStats(); } void llvm::format_provider<ConstString>::format(const ConstString &CS, |
