Skip to content

Commit

Permalink
Failed attempt at making memory measurement more reliable
Browse files Browse the repository at this point in the history
  • Loading branch information
pitrou committed Sep 27, 2023
1 parent 4f1653a commit fe4f899
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
7 changes: 6 additions & 1 deletion csharp/test/Apache.Arrow.IntegrationTest/CDataInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,14 @@ public static JsonFile ParseJsonFile(String jsonPath)
return JsonFile.Parse(new FileInfo(jsonPath));
}

public static long GetAllocatedBytes()
public static void RunGC()
{
GC.Collect();
GC.WaitForPendingFinalizers();
}

public static long GetAllocatedBytes()
{
// XXX this doesn't seem to give stable and reliable measurements
var gcInfo = GC.GetGCMemoryInfo();
return gcInfo.PromotedBytes;
Expand Down
8 changes: 7 additions & 1 deletion dev/archery/archery/integration/tester_csharp.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# under the License.

from contextlib import contextmanager
import gc
import os

from . import cdata
Expand Down Expand Up @@ -135,7 +136,12 @@ def supports_releasing_memory(self):

def gc_until(self, predicate):
from Apache.Arrow.IntegrationTest import CDataInterface
CDataInterface.GetAllocatedBytes() # implicit GC
for i in range(3):
if predicate():
return True
# Collect any C# objects hanging around through Python
gc.collect()
CDataInterface.RunGC()
return predicate()


Expand Down

0 comments on commit fe4f899

Please sign in to comment.