diff options
author | Arne Juul <arnej@verizonmedia.com> | 2020-09-08 11:48:09 +0000 |
---|---|---|
committer | Arne Juul <arnej@verizonmedia.com> | 2020-09-09 10:32:38 +0000 |
commit | cd0e5fae5156294354ad589b0148853266c79500 (patch) | |
tree | 168ef2cb137edc3ecf96a47d6df50df7e4e12037 /vespalib | |
parent | 1fa9e7b77d2779397dc7c57ecca65876c0d73eb4 (diff) |
add methods to extract memory usage
Diffstat (limited to 'vespalib')
-rw-r--r-- | vespalib/src/vespa/vespalib/stllike/string.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/vespalib/src/vespa/vespalib/stllike/string.h b/vespalib/src/vespa/vespalib/stllike/string.h index aa1e3677532..121a243d403 100644 --- a/vespalib/src/vespa/vespalib/stllike/string.h +++ b/vespalib/src/vespa/vespalib/stllike/string.h @@ -528,6 +528,13 @@ public: void reserve(size_type newCapacity) { reserveBytes(newCapacity + 1); } + + size_t count_allocated_memory() const { + return sizeof(small_string) + isAllocated() ? _bufferSize : 0; + } + size_t count_used_memory() const { + return sizeof(small_string) - StackSize + size(); + } private: void assign_slower(const void * s, size_type sz) __attribute((noinline)); void init_slower(const void *s) noexcept __attribute((noinline)); |