witwall / pdfviewer-win32

Automatically exported from code.google.com/p/pdfviewer-win32
1 stars 1 forks source link

Memory leak in PDFWrapper #35

Open amigobv opened 8 years ago

amigobv commented 8 years ago

It seems that the PDFWrapper has a memory leak. I made a performance test with Telerik JustTrace and I figured out that the PDFWrapper hast a memory leak.

I use PdfLibNet to create a JPG files from PDF documents. I create a instance of PDFWrapper in a using block for every document. Inside the using block I load the file and call the method ExportJpg. After that I wait until the isBusy flag is reset. So I don't use the ExportJpgProgressHandler or the ExportJpgFinishedHandler. JustTrace shows me that the GC cannot collect the PDFWrapper objects because of this two events ExportJpgProgressHandler and ExportJpgFinishedHandler are holding a reference. But I didn't registered any delegate on this two handlers.

I looked through the code and I can see that the _evExportJpgProgress and _evExportJpgFinished Handlers in PDFWrapper are never released. Furthermore the method ExportJpg registers the _internalExportJpgFinished and _internalExportJpgProgress to the AfPDFDocInterop instance by calling the SetExportFinishedHandler and SetExportProgressHandler methods. But this two Handler that are set by the ExportJpg method are never released!!!