Skip to content

Commit 9c32a87

Browse files
authored
fix resources leak (#2200)
1 parent a4ab68f commit 9c32a87

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/BenchmarkDotNet/Loggers/Broker.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,15 @@ internal void ProcessData()
5555

5656
writer.WriteLine(Engine.Signals.Acknowledgment);
5757

58-
if (signal == HostSignal.AfterAll)
58+
if (signal == HostSignal.BeforeAnythingElse)
59+
{
60+
// The client has connected, we no longer need to keep the local copy of client handle alive.
61+
// This allows server to detect that child process is done and hence avoid resource leak.
62+
// Full explanation: https://stackoverflow.com/a/39700027
63+
inputFromBenchmark.DisposeLocalCopyOfClientHandle();
64+
acknowledgments.DisposeLocalCopyOfClientHandle();
65+
}
66+
else if (signal == HostSignal.AfterAll)
5967
{
6068
// we have received the last signal so we can stop reading from the pipe
6169
// if the process won't exit after this, its hung and needs to be killed

0 commit comments

Comments
 (0)