/src/rocksdb/db/blob/blob_contents.cc
Line | Count | Source (jump to first uncovered line) |
1 | | // Copyright (c) Meta Platforms, Inc. and affiliates. |
2 | | // This source code is licensed under both the GPLv2 (found in the |
3 | | // COPYING file in the root directory) and Apache 2.0 License |
4 | | // (found in the LICENSE.Apache file in the root directory). |
5 | | |
6 | | #include "db/blob/blob_contents.h" |
7 | | |
8 | | #include <cassert> |
9 | | |
10 | | #include "cache/cache_entry_roles.h" |
11 | | #include "cache/cache_helpers.h" |
12 | | #include "port/malloc.h" |
13 | | |
14 | | namespace ROCKSDB_NAMESPACE { |
15 | | |
16 | 0 | size_t BlobContents::ApproximateMemoryUsage() const { |
17 | 0 | size_t usage = 0; |
18 | |
|
19 | 0 | if (allocation_) { |
20 | 0 | MemoryAllocator* const allocator = allocation_.get_deleter().allocator; |
21 | |
|
22 | 0 | if (allocator) { |
23 | 0 | usage += allocator->UsableSize(allocation_.get(), data_.size()); |
24 | 0 | } else { |
25 | 0 | #ifdef ROCKSDB_MALLOC_USABLE_SIZE |
26 | 0 | usage += malloc_usable_size(allocation_.get()); |
27 | | #else |
28 | | usage += data_.size(); |
29 | | #endif |
30 | 0 | } |
31 | 0 | } |
32 | |
|
33 | 0 | #ifdef ROCKSDB_MALLOC_USABLE_SIZE |
34 | 0 | usage += malloc_usable_size(const_cast<BlobContents*>(this)); |
35 | | #else |
36 | | usage += sizeof(*this); |
37 | | #endif |
38 | |
|
39 | 0 | return usage; |
40 | 0 | } |
41 | | |
42 | | } // namespace ROCKSDB_NAMESPACE |