Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions tests/IronPython.Tests/Stress/Engine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,15 @@ public void ScenarioXGC() {
// free up weak data structures held onto by the Python runtime
_pe.Execute("import gc\ngc.collect()");

long finalMemory = GetTotalMemory();
long memoryUsed = finalMemory - initialMemory;
const long memoryThreshold = 100000;
long memoryUsed = GetTotalMemory() - initialMemory;

// The measurement can include memory that is only released a moment later, so measure again
// before failing. A leak stays over the threshold.
for (int attempt = 0; attempt < 5 && memoryUsed > memoryThreshold; attempt++) {
System.Console.WriteLine("ScenarioGC used {0} bytes of memory, measuring again.", memoryUsed);
memoryUsed = GetTotalMemory() - initialMemory;
}

bool emitsUncollectibleCode = Snippets.Shared.SaveSnippets || _env.Setup.DebugMode;
if (!emitsUncollectibleCode)
Expand Down
Loading