mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2025-05-11 10:25:47 +02:00
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:
parent
0997e68ddd
commit
39a00806c9
3 changed files with 42 additions and 10 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue