fix(stream_family): Fix memory tracking for the STREAMs. SECOND PR (#4781)

* fix(stream_family): Fix memory tracking for the STREAMs

Signed-off-by: Stepan Bagritsevich <stefan@dragonflydb.io>

* refactor: address comments

Signed-off-by: Stepan Bagritsevich <stefan@dragonflydb.io>

---------

Signed-off-by: Stepan Bagritsevich <stefan@dragonflydb.io>
This commit is contained in:
Stepan Bagritsevich 2025-04-14 13:07:17 +02:00 committed by GitHub
parent 0997e68ddd
commit 39a00806c9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 42 additions and 10 deletions

View file

@ -941,14 +941,11 @@ void CompactObj::SetJsonSize(int64_t size) {
}
void CompactObj::AddStreamSize(int64_t size) {
if (size < 0) {
// We might have a negative size. For example, if we remove a consumer,
// the tracker will report a negative net (since we deallocated),
// so the object now consumes less memory than it did before. This DCHECK
// is for fanity and to catch any potential issues with our tracking approach.
DCHECK(static_cast<int64_t>(u_.r_obj.Size()) >= size);
}
u_.r_obj.SetSize((u_.r_obj.Size() + size));
// We might have a negative size. For example, if we remove a consumer,
// the tracker will report a negative net (since we deallocated),
// so the object now consumes less memory than it did before. This DCHECK
// is for fanity and to catch any potential issues with our tracking approach.
u_.r_obj.SetSize(UpdateSize(u_.r_obj.Size(), size));
}
void CompactObj::SetJson(const uint8_t* buf, size_t len) {