OutOfMemoryException merging PDF Aspose.Total Cloud

Hello,

we are trying to merge pdf’s by using the rest api PutMergeDocuments method but sometimes (normally when resultant pdf total size is higher than 10MB) we obtain a OutOfMemoryException. I dont think the file is important because we have been using diferent files and the same errors are obtained.

Here you have the stack trace of error#1:

Error: PutMergeDocuments. Parameters: name ‘pdfsResultado.pdf’, mergeDocuments ‘{“List”:[“f75fd91e-e7d1-4196-9db1-afb46606aa36\a.pdf”,“f75fd91e-e7d1-4196-9db1-afb46606aa36\b.pdf”]}’, storage ‘asposepdfpro’, folder ‘f75fd91e-e7d1-4196-9db1-afb46606aa36’. Error result: System.OutOfMemoryException: Out of memory. at System.Drawing.Bitmap…ctor(Stream stream) at Aspose.Pdf.XImage.#=zJMXNCYX_fFnn(Stream #=zQnlNbJo=, Document #=zHj5X048=) at Aspose.Pdf.XImage.#=zJMXNCYX_fFnn() at Aspose.Pdf.XImage.get_Grayscaled() at Aspose.Pdf.Cloud.Business.ImagePresentation…ctor(XImage image, PresentationUriBuilder uriBuilder, ImageCollection imageCollection, Rectangle _rectangle, Int32 pageNumber) in C:\ms\src\Aspose.PDF.Cloud\Business\Images\ImagePresentation.cs:line 26 at Aspose.Pdf.Cloud.Business.ImageCollection…ctor(PresentationUriBuilder uriBuilder, ImagePlacementCollection imagePlacements, Int32 pageNumber) in C:\ms\src\Aspose.PDF.Cloud\Business\Images\ImageCollection.cs:line 24 at Aspose.Pdf.Cloud.Business.PdfPagePresentation.get_Images() in C:\ms\src\Aspose.PDF.Cloud\Business\PdfPagePresentation.cs:line 186 at Aspose.Pdf.Cloud.Business.PresentationExtension.ToDTO(PageCollection pages) in C:\ms\src\Aspose.PDF.Cloud\Business\PresentationExtension.cs:line 53 at Aspose.Pdf.Cloud.Business.PresentationExtension.ToDTO(IPdfDocumentPresentation presentation) in C:\ms\src\Aspose.PDF.Cloud\Business\PresentationExtension.cs:line 35 at Aspose.Pdf.Cloud.Business.ResponseExtension.ToResponse(IPdfDocumentPresentation presentation) in C:\ms\src\Aspose.PDF.Cloud\Business\ResponseExtension.cs:line 23 at Aspose.Pdf.Cloud.Controllers.MergeController.PutMergeDocuments(String name, String appSid, MergeDocuments mergeDocuments, String storage, String folder) in C:\ms\src\Aspose.PDF.Cloud\Controllers\MergeController.cs:line 82.

and error#2:

Error: PutMergeDocuments. Parameters: name ‘pdfsResultado.pdf’, mergeDocuments ‘{“List”:[“d9a664aa-a099-4423-b074-e95e13464ec1\pdfsResultado - Copy.pdf”,“d9a664aa-a099-4423-b074-e95e13464ec1\pdfsResultado.pdf”]}’, storage ‘asposepdfpro’, folder ‘d9a664aa-a099-4423-b074-e95e13464ec1’. Error result: System.InvalidOperationException: Could not merge documents. See inner exceptions for details. —> System.OutOfMemoryException: Exception of type ‘System.OutOfMemoryException’ was thrown. at System.IO.MemoryStream.set_Capacity(Int32 value) at System.IO.MemoryStream.EnsureCapacity(Int32 value) at System.IO.MemoryStream.Write(Byte[] buffer, Int32 offset, Int32 count) at #=z2ufRI23shEN4KyuIjhj23ILyzyffVt86hQsxYLY=.#=zJglEBy0=(Byte[] #=zZGQm7EQ=, Int32 #=zXR2q0no=, Int32 #=zDy$dubY=) at #=zbcJOOSRlgSRCXIVJN$Uh_0flgYUEAswYPQ==.#=ztoBLvsc=.#=zn1YpQYM=(#=z$dxKBEAN91QnqlPIWVaHqnFGCkQdTIpyard9$YUL8MYp #=zqNKZOQeAGlqz, #=z9mDHqVYfX$_GEpIbXgNiuvra7DP073WgVg== #=zJ8hr0B3ISa2E, Boolean #=zBYCHPLPtB1tF, Int64& #=zXR2q0no=) at #=zbcJOOSRlgSRCXIVJN$Uh_0flgYUEAswYPQ==.#=ztoBLvsc=.#=zn1YpQYM=(#=z$dxKBEAN91QnqlPIWVaHqnFGCkQdTIpyard9$YUL8MYp #=zqNKZOQeAGlqz, #=z9mDHqVYfX$_GEpIbXgNiuvra7DP073WgVg== #=zJ8hr0B3ISa2E) at #=zc_Iw$jN6VZ3CeoK8_qFF2OBl8Sz18_5l6INg2B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dTIpyard9$YUL8MYp #=zqNKZOQeAGlqz, #=z9mDHqVYfX$_GEpIbXgNiuvra7DP073WgVg== #=zJ8hr0B3ISa2E, Int64& #=zXR2q0no=) at #=zXX9R9yGWV0GsOE7Kaa11IIhBSRBBDMt5fkOMqGTaTFPfYFjrqOxvu5E=.#=zxWuOC2U=(#=z$dxKBEAN91QnqlPIWVaHqnFGCkQdTIpyard9$YUL8MYp #=zqNKZOQeAGlqz, #=zM9aRlL6WFPKtGYQrz_64YvhR425lF3p_E6yQBA0= #=znBYtyWE=) at (Object , Object[] ) at #=qVNVRJVzHhGDD2q4TVWbHKipS1r2Snc1magmrG2lXjy0=.#=z4nKmKQrNAbz49Fm6u6Wx9psivcoAT8_1KaFY7wQ=(MethodBase #=zfTzq_eo=, Object #=zrJcNi5M=, Object[] #=zYSRNyLE=, Boolean #=zOumeXqU=) at #=qVNVRJVzHhGDD2q4TVWbHKipS1r2Snc1magmrG2lXjy0=.#=zfTkmkI11VcaffwEV7wQmM2MDp8lOSQS$Re53S0N9PEIN(MethodBase #=zfTzq_eo=, Boolean #=zrJcNi5M=) at #=qVNVRJVzHhGDD2q4TVWbHKipS1r2Snc1magmrG2lXjy0=.#=zRQkoH8U425weVu5rdAPBKS0=(#=qVNVRJVzHhGDD2q4TVWbHKipS1r2Snc1magmrG2lXjy0= #=zfTzq_eo=, #=q3JvupNWAWIt1hQXkpqrRFdRhJk4c5mhn_1zRI8y2cKU= #=zrJcNi5M=) at #=qVNVRJVzHhGDD2q4TVWbHKipS1r2Snc1magmrG2lXjy0=.#=z6p5H0bqLYIenHr2bSmA5siWa05FouZai0ydt6dQ=() at #=qVNVRJVzHhGDD2q4TVWbHKipS1r2Snc1magmrG2lXjy0=.#=zfMJu4Bql9NzLmGiVvyNfdj4Ba_U8N7v1JGI2IUE=(Boolean #=zfTzq_eo=) at #=qVNVRJVzHhGDD2q4TVWbHKipS1r2Snc1magmrG2lXjy0=.#=zA5SxWD_pK_XqWE6zyw5ZFHQryncRJQ9shRr5Z1xxHxQ4(Object #=zfTzq_eo=) at #=qVNVRJVzHhGDD2q4TVWbHKipS1r2Snc1magmrG2lXjy0=.#=zBhnA4ZSQ4DEkoBxZ79xTHMbbmJB4_ubTSA==() at #=qVNVRJVzHhGDD2q4TVWbHKipS1r2Snc1magmrG2lXjy0=.#=zfoq0Owq94AOhkhtlCogbxkr4ebjHtjPKVV1VA1M=(Object #=zfTzq_eo=, UInt32 #=zrJcNi5M=) at #=qVNVRJVzHhGDD2q4TVWbHKipS1r2Snc1magmrG2lXjy0=.#=zfMJu4Bql9NzLmGiVvyNfdj4Ba_U8N7v1JGI2IUE=(Boolean #=zfTzq_eo=) at #=qVNVRJVzHhGDD2q4TVWbHKipS1r2Snc1magmrG2lXjy0=.#=zvVW5eJQgDuvZQnR5I3Li7$$pTublBvQObnok_Xo=() at #=qVNVRJVzHhGDD2q4TVWbHKipS1r2Snc1magmrG2lXjy0=.#=z1t9JIq1UYn29co3hzywaKpI=(Object[] #=zfTzq_eo=, Type[] #=zrJcNi5M=, Type[] #=zYSRNyLE=, Object[] #=zOumeXqU=) at #=qVNVRJVzHhGDD2q4TVWbHKipS1r2Snc1magmrG2lXjy0=.#=zyISS6VwNO05TV5QI1c_kdUEhZhAGEgPnftmQ8wc=(Stream #=zfTzq_eo=, String #=zrJcNi5M=, Object[] #=zYSRNyLE=, Type[] #=zOumeXqU=, Type[] #=zO0crUDw=, Object[] #=zJrFPpfU=) at #=qVNVRJVzHhGDD2q4TVWbHKipS1r2Snc1magmrG2lXjy0=.#=z5j18LNHUhmH22P2IKTuPbiWPWVxKF21Kp0TMUw4=(Stream #=zfTzq_eo=, String #=zrJcNi5M=, Object[] #=zYSRNyLE=) at #=qVNVRJVzHhGDD2q4TVWbHKipS1r2Snc1magmrG2lXjy0=.#=zaQg$ZgBKjg6vIuYFhfrsku0tarjpPQ6fSA==(Stream #=zfTzq_eo=, String #=zrJcNi5M=, Object[] #=zYSRNyLE=) at #=zRAhI0pPiSmM4tNL5gFnCTga4hn9ZX$7b2Q==.#=zxWuOC2U=() at #=zolizZEOJAndYakPP6O4z9_bOo6RayHcpJg==.#=zxWuOC2U=(Stream #=zn$yR1t8=) at #=z9TwjKQdR7_Z7v7UV_kAbTVZNkpLv.#=zxWuOC2U=(Stream #=zn$yR1t8=) at Aspose.Pdf.Document.#=zgRidtaqOJiCj(Stream #=zXh7sqME=, SaveOptions #=z$EqHIv7hQ3h1) at Aspose.Pdf.Document.Save(Stream output) at Aspose.Pdf.Facades.PdfFileEditor.Concatenate(Stream[] inputStream, Stream outputStream) — End of inner exception stack trace — at Aspose.Pdf.Cloud.Business.DocumentCreation.DocumentCreationManagerLegacy.Merge(IFileManagerWrapper fileManager, String requestRoot, IList1 files, String outputFile) in C:\ms\src\Aspose.PDF.Cloud\Business\DocumentCreation\DocumentCreationManagerLegacy.cs:line 138 at Aspose.Pdf.Cloud.Business.PdfDocumentManager.Merge(IFileManagerWrapper fileManager, String requestRoot, IList1 files, String outputFile) in C:\ms\src\Aspose.PDF.Cloud\Business\PdfDocumentManager.cs:line 384 at Aspose.Pdf.Cloud.Controllers.MergeController.PutMergeDocuments(String name, String appSid, MergeDocuments mergeDocuments, String storage, String folder) in C:\ms\src\Aspose.PDF.Cloud\Controllers\MergeController.cs:line 80.

Thanks in advance.
Best regards

@DKVDesarrollo

I have tested the scenario with two PDF files of 8+ MB size each and unable to replicate the issue. Please share your problematic document here. We will look into it and will guide you accordingly.

Hello and thanks in advance for your quick reply.

Here you can download the file we have been tested today: https://medicos.dkvseguros.com/ccmpdfs/Privada_ARAGONSORIA_ES.PDF

the trace we find out in the aspose usage log is the following:

Error: UploadFile. Parameters: path ‘445a04c7-578b-450d-9719-d542551c0600/Privada_ARAGONSORIA_ES.PDF’, storageName ‘asposepdfpro’. Exception: Exception of type ‘System.OutOfMemoryException’ was thrown…

Regards

@DKVDesarrollo

We have tested the scenario with your shared PDF document and unable to replicate the reported exception. We will appreciate it, if you please share your credentials (App Key and SID) via private message (click on my username in the thread and use message option). We will further investigate the issue and will share our findings.

Hi Again,

We have been tested again and it turns out that the files are uploaded successfully, the problem we have now is in the merge operation because the response object returned is always empty (with bigger files, higher than 10MB)

An here you have an image of the API function we are using to invoke the merge we have against a custom Azure blob storage);

asposefirststorage.png (47.1 KB)

And here the error against a dafault storage created by aspose (First Storage). Different error but the response is empty as well

azureblobstorage.png (49.0 KB)

Can you check if we have to use another api function or what are we soing bad?

Thanks in advance

@DKVDesarrollo

As stated above, we have tested the merge API and unable to replicate the issue. Please share your credentials in a private message. We will try to replicate the issue and fix it.

@DKVDesarrollo

We have tested the scenario with your shared PDF document and credentials. And we noticed that PutMergeDocuments API is working fine in cURL, however, it is not working with Aspose.PDF Cloud SDK for .NET as expected. We have logged a ticket PDFCLOUD-1640 in our issue tracking system for rectification. We will keep you updated about the issue resolution progress.

Thank you tilal.ahmad,

We have been experienced the same problem in the PDF to Word conversion (you can test it whit the same file). It returns an error after about two minutes. The api function we use is the following:

apiClient = new PdfApi(ConfigSettings.Aspose.AppKey, ConfigSettings.Aspose.AppSid);

resultConvert = apiClient.PutPdfInRequestToDoc(Path.Combine(destinationFolder, fileResult), file: fileConvert.OpenReadStream(), format: “docx”, storage: storageName);

Please, check if you have the same problem with it. When we use smaller pdf files (5MB or less) it works properly

Thanks in advance

Regards

@DKVDesarrollo

Thanks for your feedback. We have noticed the issue with PutPdfInRequestToDoc and logged a ticket PDFCLOUD-1639 for investigation and rectification. We will notify you as soon as it is resolved.

Hello,

I notice that issues PDFCLOUD-1639 and 1640 are in Closed Status. Does it mean that the issue has been fixed?

Regards

@DKVDesarrollo

Yes, we have just released Aspose.PDF Cloud API 20.8. The OutOfMemory issue was causing because of low memory of Aspose.PDF Cloud production server instance. We have increased the memory to resolve the issue and we will further optimize the memory management in September, 2020 release.

Thank you!

We will check asap.

1 Like