Release memory after converting a document to PDF in .NET

We have developed a windows service using GroupDocs.Conversion for .NET 19.1
We see that when we call conversion functions, memory is consumed and never released.
Our implementation is based in the code sample.

GroupDocs.Conversion.Config.ConversionConfig config = new GroupDocs.Conversion.Config.ConversionConfig {
StoragePath = “.”,
OutputPath = “.”,
TempDataHandler = new MyTempDataHandler ()
};

GroupDocs.Conversion.Handler.ConversionHandler Handler = new GroupDocs.Conversion.Handler.ConversionHandler (config);
var result = Handler.Convert (source, new GroupDocs.Conversion.Options.Save.PdfSaveOptions ());
result.Save (target);

We have tried calling GC.Collector, but it does not work.

After a while, the service demands too much memory and stops working.

@berenice.lopez,

Can you please share a simple (console based) application along-with sample document/file using that issue could be reproduced? Also share screen-cast of memory usage and not released back.
We tried to reproduce this issue at our end but API doesn’t consume much memory and releases the memory once conversion process is completed - memory usage.JPG (30.2 KB)

I attach a console application, the code and the source file we are using. The applications goes into a loop that converts the source file. It usually converts fine the first time, after the second or third convertion a memory exception is thrown. Then the convertion is tried again and works fine but the memory error happends again.

This is the error exception output.

at Aspose.Slides.Presentation.:slight_smile:(Stream :slight_smile:)
at Aspose.Slides.Presentation…ctor(Stream stream, LoadOptions loadOptions)
at :spades: .:heart:? ? (LoadOptions :slight_smile:)
at :heart:? .:slight_smile:? ? :slight_smile:(Stream :slight_smile:, LoadOptions :heart:)
at? .:slight_smile:(FileDescription :slight_smile:, Stream :heart:, LoadOptions :clubs:, SaveOptions)
at? .:clubs:? ? :slight_smile:(String :slight_smile:, LoadOptions :heart:, SaveOptions :clubs:)
at GroupDocs.Conversion.Handler.ConversionHandler.Convert(String guid, LoadOptions loadOptions, SaveOptions saveOptions)
at GroupDocs.Conversion.Handler.ConversionHandler.Convert(String guid, SaveOptions saveOptions)
at testPdf.Program.Main(String[] args) in c:\Users\Antonio\Documents\Visual Studio 2012\Projects\CommerceFiel\testPdf\Program.cs:line 27
Contador: 27
Aspose.Slides.PptxReadException: Out of memory. —> System.OutOfMemoryException: Out of memory.
at System.Drawing.Image.FromStream(Stream stream, Boolean useEmbeddedColorManagement, Boolean validateImageData)
at System.Drawing.Image.FromStream(Stream stream)
at Aspose.Slides.ImageCollection.AddImage(MemoryStream stream)
at Aspose.Slides.ImageCollection.AddImage(Byte[] buffer)
at Aspose.Slides.:clubs:? ?.:heart: :slight_smile:)
at Aspose.Slides.:clubs:? ?. :slight_smile:)
at Aspose.Slides? ?.:heart:(:slight_smile: :slight_smile:, IPresentation :heart:)
at Aspose.Slides? ?.:slight_smile:(Presentation :slight_smile:, Stream :heart:, InterruptionToken :clubs:)
— End of inner exception stack trace —
at Aspose.Slides? ?.:slight_smile:(Presentation :slight_smile:, Stream :heart:, InterruptionToken :clubs:)
at Aspose.Slides.Presentation.:heart:(Stream :slight_smile:, Boolean :heart:)
at Aspose.Slides.Presentation.:slight_smile:(Stream :slight_smile:, Boolean :heart:)
at Aspose.Slides.Presentation.:slight_smile:(Stream :slight_smile:)
at Aspose.Slides.Presentation…ctor(Stream stream, LoadOptions loadOptions)
at :spades: .:heart:? ? (LoadOptions :slight_smile:)
at :heart:? .:slight_smile:? ? :slight_smile:(Stream :slight_smile:, LoadOptions :heart:)
at? .:slight_smile:(FileDescription :slight_smile:, Stream :heart:, LoadOptions :clubs:, SaveOptions)
at? .:clubs:? ? :slight_smile:(String :slight_smile:, LoadOptions :heart:, SaveOptions :clubs:)
at GroupDocs.Conversion.Handler.ConversionHandler.Convert(String guid, LoadOptions loadOptions, SaveOptions saveOptions)
at GroupDocs.Conversion.Handler.ConversionHandler.Convert(String guid, SaveOptions saveOptions)
at testPdf.Program.Main(String[] args) in c:\Users\Antonio\Documents\Visual Studio 2012\Projects\CommerceFiel\testPdf\Program.cs:line 27
Contador: 28testPdf.zip (2.5 KB)
sample_code.zip (500 Bytes)

@berenice.lopez,

Please share problematic file again. testPDF folder only contains a exe file.

Sorry for the delay. I attach the sample file…

I think the problem is the size… Can you share with me an email account to send the link to download?

@berenice.lopez,

Please upload the problematic file to some cloud storage (Dropbox, Google drive etc.) and post the shareable link here. You can delete the file from storage once we download it.