Skip to content

Commit ca059b5

Browse files
grisha-kotlerarekpalinski
authored andcommitted
RavenDB-23704 - fix the calculation of AdditionalMemory to include the allocated memory in the Allocator
1 parent 498afcb commit ca059b5

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

src/Voron/Impl/LowLevelTransaction.cs

+17-5
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,18 @@ public void Reset()
9696

9797
public event Action<LowLevelTransaction> LastChanceToReadFromWriteTransactionBeforeCommit;
9898

99-
public Size TransactionSize => new Size(NumberOfModifiedPages * Constants.Storage.PageSize, SizeUnit.Bytes) + AdditionalMemoryUsageSize;
99+
public Size TransactionSize => new Size(NumberOfModifiedPages * Constants.Storage.PageSize, SizeUnit.Bytes) + new Size(TotalEncryptionBufferInBytes + DecompressedBufferBytes, SizeUnit.Bytes);
100100

101-
public Size AdditionalMemoryUsageSize
101+
public long TotalAllocatedInBytes => _allocator._totalAllocated;
102+
103+
public long TotalEncryptionBufferInBytes
102104
{
103105
get
104106
{
107+
108+
var total = 0L;
109+
105110
var cryptoTransactionStates = ((IPagerLevelTransactionState)this).CryptoPagerTransactionState;
106-
107-
var total = DecompressedBufferBytes;
108111

109112
if (cryptoTransactionStates != null)
110113
{
@@ -114,9 +117,18 @@ public Size AdditionalMemoryUsageSize
114117
}
115118
}
116119

117-
return new Size(total, SizeUnit.Bytes);
120+
return total;
118121
}
119122
}
123+
124+
public Size AdditionalMemoryUsageSize
125+
{
126+
get
127+
{
128+
return new Size(_allocator._totalAllocated + TotalEncryptionBufferInBytes, SizeUnit.Bytes);
129+
}
130+
}
131+
120132
public event Action<IPagerLevelTransactionState> OnDispose;
121133

122134
/// <summary>

0 commit comments

Comments
 (0)