Skip to content

Commit

Permalink
Improve accuracy of reported memsizes
Browse files Browse the repository at this point in the history
Following from the improvements for RE2::MatchData's reported memsize
with ObjectSpace.dump and ObjectSpace.memsize_of, do the same for
RE2::Regexp, RE2::Set and RE2::Scanner. Previously, we used the size of
the pointer in the data structure rather than the size of the allocated
memory.
  • Loading branch information
mudge committed Nov 17, 2023
1 parent 41094bd commit 2e44226
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions ext/re2/re2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ static size_t re2_scanner_memsize(const void *ptr) {
const re2_scanner *s = reinterpret_cast<const re2_scanner *>(ptr);
size_t size = sizeof(*s);
if (s->input) {
size += sizeof(s->input);
size += sizeof(*s->input);
}

return size;
Expand Down Expand Up @@ -232,7 +232,7 @@ static size_t re2_regexp_memsize(const void *ptr) {
const re2_pattern *p = reinterpret_cast<const re2_pattern *>(ptr);
size_t size = sizeof(*p);
if (p->pattern) {
size += sizeof(p->pattern);
size += sizeof(*p->pattern);
}

return size;
Expand Down Expand Up @@ -1591,7 +1591,7 @@ static size_t re2_set_memsize(const void *ptr) {
const re2_set *s = reinterpret_cast<const re2_set *>(ptr);
size_t size = sizeof(*s);
if (s->set) {
size += sizeof(s->set);
size += sizeof(*s->set);
}

return size;
Expand Down

0 comments on commit 2e44226

Please sign in to comment.