OpenOffice C # memory leak

I noticed a memory leak in my application and tried to figure it out. I don’t know what good and free memory leaks detection methods (any suggestions?), So I did it simply by inserting printouts of memory usage (with and without GC), and then digging deeper where there was a big leak. I fixed Fixable, but some cannot, because they are inside packages. Like this very simplistic

using System;
using System.Threading;
using DocumentFormat.OpenXml.Packaging;

namespace WorkTest
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("0) " + System.GC.GetTotalMemory(true).ToString("000,000,000", Thread.CurrentThread.CurrentCulture));
            Console.WriteLine("Start");
            Console.WriteLine("1) " + System.GC.GetTotalMemory(true).ToString("000,000,000", Thread.CurrentThread.CurrentCulture));

            using (WordprocessingDocument wordPackage = WordprocessingDocument.Open(@"c:\tmp\a.docx", true))
            {
              // This is Open XML Format SDK 2.5 - v4.0.30319
              // It does nothing within this particular block/example 
            }
            Console.WriteLine("2) " + System.GC.GetTotalMemory(true).ToString("000,000,000", Thread.CurrentThread.CurrentCulture));
            Console.WriteLine("End");
            Console.WriteLine("3) " + System.GC.GetTotalMemory(true).ToString("000,000,000", Thread.CurrentThread.CurrentCulture));
        }
    }
}

usually it creates something like

0) 000,215,984
Start
1) 000,218,528
2) 000,325,472
End
3) 000,325,472

To start with a small leak - step 0-1 is a simple conclusion. He did not eat much. Only 3K, but it's still something. Step 2-3 is the same, but there is nothing. OK. I agree. Some I / O packets may require some memory. Not good, but understandable.

- 1-2 . "" {} . . . . , , . 90K. 100 9Mb.

, GC . , GC , 4K . , .

- , . , .

+4
1

, , ADPlus WinDbg . Google .

. , , , Visual Studio 2013. ANALYZE → .NET.

+1

All Articles