Skip to content

Commit c2694e0

Browse files
committed
fix: compute_memory_size() updated
1 parent 449ef75 commit c2694e0

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

include/jsoncons/basic_json.hpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2176,10 +2176,9 @@ namespace jsoncons {
21762176
// Get array internal storage
21772177
const array& arr = current->template cast<array_storage>().value();
21782178

2179-
// Memory for the array object itself
2180-
mem_size += sizeof(array);
2181-
21822179
// Memory for the array's internal buffer
2180+
// Note: We only count dynamically allocated memory (heap).
2181+
// The array object itself is part of array_storage allocation.
21832182
if (!arr.empty())
21842183
{
21852184
// Get pointer to internal vector buffer
@@ -2201,10 +2200,9 @@ namespace jsoncons {
22012200
// Get object internal storage
22022201
const object& obj = current->template cast<object_storage>().value();
22032202

2204-
// Memory for the object itself
2205-
mem_size += sizeof(object);
2206-
22072203
// Memory for the object's internal storage (vector of key_value_type)
2204+
// Note: We only count dynamically allocated memory (heap).
2205+
// The object itself is part of object_storage allocation.
22082206
if (!obj.empty())
22092207
{
22102208
// Get pointer to internal vector buffer via iterator

0 commit comments

Comments
 (0)