Skip to content

Commit 03bce24

Browse files
authored
Fixed leak in object pool (#5521)
1 parent c9ec20b commit 03bce24

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/Microsoft.ML.Data/Data/DataViewUtils.cs

+4-2
Original file line numberDiff line numberDiff line change
@@ -942,8 +942,10 @@ public override void Set(BatchColumn batchCol)
942942
public override void Unset()
943943
{
944944
Contracts.Assert(_index <= _count);
945-
if (Values != null)
946-
_pool.Return(Values);
945+
// Remove all the objects from the pool
946+
// to free up references to those objects
947+
while (_pool.Count > 0)
948+
_pool.Get();
947949
Values = null;
948950
_count = 0;
949951
_index = 0;

test/Microsoft.ML.TestFramework/BaseTestClass.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ void IDisposable.Dispose()
8181
Cleanup();
8282
Process proc = Process.GetCurrentProcess();
8383
Console.WriteLine($"Finished test: {FullTestName} " +
84-
$"with memory usage {proc.PrivateMemorySize64.ToString("N", CultureInfo.InvariantCulture)}");
84+
$"with memory usage {proc.WorkingSet64.ToString("N", CultureInfo.InvariantCulture)}");
8585
}
8686

8787
protected virtual void Initialize()

0 commit comments

Comments
 (0)