Skip to content

Commit

Permalink
Implemented a tracking mechanism to troubleshoot non disposed resourc…
Browse files Browse the repository at this point in the history
…es in TemporaryBuffer.
  • Loading branch information
nulltoken committed Nov 17, 2009
1 parent 9d0de59 commit 9dd0757
Showing 1 changed file with 25 additions and 25 deletions.
50 changes: 25 additions & 25 deletions GitSharp.Core/Util/TemporaryBuffer.cs
Expand Up @@ -204,19 +204,33 @@ private bool reachedInCoreLimit()
}

public void close()
{
if (diskOut != null)
{
if (diskOut == null)
{
return;
}

try
{
try
{
diskOut.Close();
}
finally
{
diskOut = null;
}
diskOut.Dispose();
}
finally
{
diskOut = null;
}

#if DEBUG
GC.SuppressFinalize(this); // Disarm lock-release checker
#endif
}

#if DEBUG
// A debug mode warning if the type has not been disposed properly
~TemporaryBuffer()
{
Console.Error.WriteLine(GetType().Name + " has not been properly disposed.");
}
#endif

/**
* Obtain the length (in bytes) of the buffer.
Expand Down Expand Up @@ -325,21 +339,7 @@ public void destroy()
{
_blocks = null;

if (diskOut != null)
{
try
{
diskOut.Close();
}
catch (IOException)
{
// We shouldn't encounter an error closing the file.
}
finally
{
diskOut = null;
}
}
close();

if (_onDiskFile != null)
{
Expand Down

0 comments on commit 9dd0757

Please sign in to comment.