Skip to content
This repository was archived by the owner on Feb 3, 2023. It is now read-only.

Commit fc88aa9

Browse files
committed
Rudimentary stream leak detection
1 parent 76cc93a commit fc88aa9

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

LibGit2Sharp/Filter.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
using System;
22
using System.Collections.Concurrent;
33
using System.Collections.Generic;
4+
using System.Diagnostics;
5+
using System.Globalization;
46
using System.IO;
57
using System.Linq;
68
using System.Runtime.InteropServices;
@@ -48,6 +50,14 @@ protected Filter(string name, IEnumerable<FilterAttributeEntry> attributes)
4850
~Filter()
4951
{
5052
GlobalSettings.DeregisterFilter(this);
53+
54+
#if LEAKS_IDENTIFYING
55+
int activeStreamCount = activeStreams.Count;
56+
if (activeStreamCount > 0)
57+
{
58+
Trace.WriteLine(string.Format(CultureInfo.InvariantCulture, "{0} leaked {1} stream handles at finalization", GetType().Name, activeStreamCount));
59+
}
60+
#endif
5161
}
5262

5363
private readonly string name;

0 commit comments

Comments
 (0)