Exception"Out of memory" when hosting Aspose.Slides on azure

Hi,


I’m attempting to use aspose slides in a webjob which is hosted on azure. The webjob, when run locally (windows 10, x64) works perfectly, but on azure, we get out of memory exceptions.

<b class=“ng-binding” style=“box-sizing: border-box; color: rgb(51, 51, 51); font-family: “Segoe UI”, sans-serif; font-size: 12px; background-color: rgb(255, 255, 255);”>Microsoft.Azure.WebJobs.Host.FunctionInvocationException<span style=“color: rgb(51, 51, 51); font-family: “Segoe UI”, sans-serif; font-size: 12px; background-color: rgb(255, 255, 255);”>: Microsoft.Azure.WebJobs.Host.FunctionInvocationException: Exception while executing function: Functions.ProceConvertSlides —> Aspose.Slides.PptxReadException: Out of memory. —> System.OutOfMemoryException: Out of memory.
at System.Drawing.Image.FromStream(Stream stream, Boolean useEmbeddedColorManagement, Boolean validateImageData)
at Aspose.Slides.ImageCollection.AddImage(MemoryStream stream)
at Aspose.Slides. .( )
at Aspose.Slides. .( )
at Aspose.Slides. .( , IPresentation )
at Aspose.Slides. .(Presentation , Stream )
— End of inner exception stack trace —
at Aspose.Slides. .(Presentation , Stream )
at Aspose.Slides.Presentation.(Stream )
at Aspose.Slides.Presentation.(Stream )
at Aspose.Slides.Presentation.(Stream )
at Aspose.Slides.Presentation…ctor(Stream stream)
at Alis.Convert.Functions.ProceConvertSlides(SlideConvert message, TextWriter log) in E:\Development\AlisConvert\Alis.Convert\Functions.cs:line 71
at lambda_method(Closure , Functions , Object[] )
at Microsoft.Azure.WebJobs.Host.Executors.VoidMethodInvoker1.InvokeAsync(TReflected instance, Object[] arguments) at Microsoft.Azure.WebJobs.Host.Executors.FunctionInvoker1.d__8.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.d__22.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.d__21.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.d__19.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.d__13.MoveNext()
— End of inner exception stack trace —
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.d__13.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.d__10.MoveNext()
<span style=“color: rgb(51, 51, 51); font-family: “Segoe UI”, sans-serif; font-size: 12px; background-color: rgb(255, 255, 255);”>
I’m downloading a blob from azure storage into a memory stream, and then passing this stream into a Presentation. This is where the exception occurs:

using (var stream = new MemoryStream())
{
blob.DownloadToStream(stream);

stream.Position = 0L;


using (var pres = new Presentation(stream))
<span style=“color: rgb(51, 51, 51); font-family: “Segoe UI”, sans-serif; font-size: 12px; background-color: rgb(255, 255, 255);”>
<span style=“color: rgb(51, 51, 51); font-family: “Segoe UI”, sans-serif; font-size: 12px; background-color: rgb(255, 255, 255);”>As mentioned above, this works perfectly on local machines.
<span style=“color: rgb(51, 51, 51); font-family: “Segoe UI”, sans-serif; font-size: 12px; background-color: rgb(255, 255, 255);”>
<span style=“color: rgb(51, 51, 51); font-family: “Segoe UI”, sans-serif; font-size: 12px; background-color: rgb(255, 255, 255);”>We’ve tried boosting the power of the webapp hosting the webjob, but even with multiple cores and 7gb memory we still get the error on pptx files larger than 10 mb.

Hi,


I have observed your comments. Can you please share complete working sample project and sample presentation to reproduce the issue. Also please share which Aspose.Slides version you are using on your end. Please share the requested information so that we can further investigate issue to help you out.

Best Regards,

I ran into this error as well. I got it when looping through the Image collection on a Presentation object and accessing the SystemImage property:

foreach(var image in presentation.Images)
{
 var format = image.SystemImage.RawFormat; //Get Out of Memory Exception (says 'Image.Clone()' in stacktrace)
}

Only on Azure of course.
I upgraded my App Service Plan to a large variant, just to try if that fixed it… it does not.

@HJdeHek,

Can you please provide the sample project, complete stack trace of issue along with inner exception details (if any). Also, please check top memory usage when this code running - if it really high (let say, more than 2Gb). Please also provide what is the type/configuration of web application you are using to run this WebJob along with source problematic presentation.

I’ve run into the same problem.
I’m using a http triggered azure function app on a ‘consumption’ plan. (I’ve also tried S1, S2 and S3 hosting plans, all with the same result)
The out of memory exception occurs in the constructor of the Presentation class, providing the pptx file as a stream.
The pptx is 2.5MB and has 29 slides, most of which have one image. Smaller pptx files work correctly.

The exception I get is:
Aspose.Slides.PptxReadException:
at Aspose.Slides. . (Aspose.Slides, Version=18.11.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56)
at Aspose.Slides.Presentation. (Aspose.Slides, Version=18.11.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56)
at Aspose.Slides.Presentation. (Aspose.Slides, Version=18.11.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56)
at Aspose.Slides.Presentation. (Aspose.Slides, Version=18.11.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56)
at Aspose.Slides.Presentation…ctor (Aspose.Slides, Version=18.11.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56)
at AsposeSlidesOutOfMemory.ConvertSlides+d__0.MoveNext (AsposeSlidesOutOfMemory, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null)
Inner exception System.OutOfMemoryException handled at Aspose.Slides. .:
at System.Drawing.Image.FromStream (System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a)
at Aspose.Slides.ImageCollection.AddImage (Aspose.Slides, Version=18.11.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56)
at Aspose.Slides. . (Aspose.Slides, Version=18.11.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56)
at Aspose.Slides. . (Aspose.Slides, Version=18.11.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56)
at Aspose.Slides. . (Aspose.Slides, Version=18.11.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56)
at Aspose.Slides. . (Aspose.Slides, Version=18.11.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56)

Attached is a sample C# project with the pptx that causes the error.

AsposeSlidesOutOfMemory.zip (2.2 MB)

@NielsM,

I have observed the information shared by you along with stack trace. An issue with ID SLIDESNET-40763 has been created in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be notified once the issue will be fixed.

Hi @mudassir.fayyaz,

we are also seeing this issue with the same stacktrace (not on Azure, normal Windows Server installation).
Is there any possible date for a fix?

Thanks
Andrea

@andreagasparin,

I have observed your comments. I regret to inform that this is currently postponed because of low priority. I also like to inform as per our company policy, the first priority for investigation is given to the Paid Support i.e. Enterprise and Priority Support on first come first serve basis. After that the issues from normal support forum are scheduled for investigation on first come first serve basis. I request for your patience.