Memory leaks when saving to word

Get technical support of PDF Focus .Net in C# and VB.Net
Lubos
Posts: 1
Joined: Fri Oct 29, 2021 3:24 pm
Contact:

Memory leaks when saving to word

Post by Lubos »

Hi, I really like this library and I'm considering buying it, but it seems to have memory leaks.
I need to convert pdf to docx. I have a very simple class to do the job

Code: Select all

public class SautinPdfConverter : IPdfConverter
{
    SautinSoft.PdfFocus pdfFocus = new SautinSoft.PdfFocus();
    public void Convert(Stream pdfStream, Stream docxStream)
    {
        pdfFocus.OpenPdf(pdfStream);
        var result = pdfFocus.ToWord(docxStream);
        if (result != 0)
        {
            var message = $"Error when converting file: {pdfFocus.Exception.Message}";
            pdfFocus.ClosePdf();
            throw new Exception(message);
        }
        pdfFocus.ClosePdf();
    }

    public void Convert(string pdfPath, string docxPath)
    {
        using (var docxStream = new FileStream(docxPath, FileMode.Create))
        using (var pdfStream = File.OpenRead(pdfPath))
        {
            Convert(pdfStream, docxStream);
        }
    }
}
 

The "Out of memory" exception is thrown when I ran my unit test on the set of files. The same situation happens with randomly selected file and running conversion repeatedly. I'm using the latest release 8.0.6.21, but I've tried also the latest beta with the same result.

Tests:

Code: Select all

	
[TestMethod]
public void CanConvertSameFileRepeatedly()
{
    var count = 200;
    var focusConverter = new SautinPdfConverter();
    
    for (int i = 0; i < count; i++)
    {
        var docxPath = ConvertFile("c:\\pdf\\mix2\\2dcke33d.pdf", focusConverter);
        File.Delete(docxPath);
    }
}	
	
public string ConvertFile(string path, IPdfConverter converter)
{
    var finfo = new FileInfo(path);
    var focusPath = Path.Combine(finfo.DirectoryName, finfo.Name + "_focus.docx");

    if (!File.Exists(focusPath))
    {
        converter.Convert(path, focusPath);
    }

    return focusPath;
}
Am I doing something wrong?
Oliver
Posts: 27
Joined: Wed Aug 19, 2020 11:59 am
Contact:

Re: Memory leaks when saving to word

Post by Oliver »

Hello.

I'll try to help you and understand why it's happening.

Could you send me any PDF file for test?

My Name is Oliver: ol@sautinsoft.com

I'm waiting your pdf. Thanks
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests