diff options
author | galaxycrab <UgnineSirdis@ydb.tech> | 2023-01-09 17:50:01 +0300 |
---|---|---|
committer | galaxycrab <UgnineSirdis@ydb.tech> | 2023-01-09 17:50:01 +0300 |
commit | 291dc87a9ae66d8c68ee96b823eda68d2285045a (patch) | |
tree | 663c1a593d634200764efc263e3015d29e7c6807 | |
parent | 953cb957602ebf288f51ee3a580f78e000c8228a (diff) | |
download | ydb-291dc87a9ae66d8c68ee96b823eda68d2285045a.tar.gz |
Fix memory leak: fill history map only when it is used
-rw-r--r-- | ydb/core/quoter/quoter_service.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/ydb/core/quoter/quoter_service.cpp b/ydb/core/quoter/quoter_service.cpp index b6cb58d2f5..24897018b7 100644 --- a/ydb/core/quoter/quoter_service.cpp +++ b/ydb/core/quoter/quoter_service.cpp @@ -254,7 +254,9 @@ void TResource::ChargeUsedAmount(double amount, TInstant now) { FreeBalance -= amount; Balance -= amount; AmountConsumed += amount; - History.Add(now, amount); + if (StatUpdatePolicy != EStatUpdatePolicy::Never) { + History.Add(now, amount); + } Counters.Consumed->Add(static_cast<i64>(amount)); if (Balance >= 0.0) { StopStarvation(now); @@ -291,7 +293,9 @@ TDuration TResource::Charge(double amount, TInstant now) { LastAllocated = Max(now - QuoterServiceConfig.ScheduleTickSize * 2, timeToFullfill); Balance -= amount; AmountConsumed += amount; - History.Add(now, amount); + if (StatUpdatePolicy != EStatUpdatePolicy::Never) { + History.Add(now, amount); + } if (FreeBalance > Balance) FreeBalance = Balance; @@ -306,7 +310,9 @@ TDuration TResource::Charge(double amount, TInstant now) { FreeBalance -= amount; Balance -= amount; AmountConsumed += amount; - History.Add(now, amount); + if (StatUpdatePolicy != EStatUpdatePolicy::Never) { + History.Add(now, amount); + } Counters.Consumed->Add(static_cast<i64>(amount)); StopStarvation(now); |