DocIO, XlsIO, Presentation - out of memory exception, although the file size is 1.75MB and 21.9MB

Hi there,

I have a docx file of 1.75MB, an xlsx file of 21.9MB, and a pptx file of 1.2GB, but syncfusion throw System.OutOfMemoryException. Please help me to review these files (please refer to the attachment).

By the way, I have a question: what is the maximum file size that syncfusion can support for office files? 

Thanks,

Tuong.


Note: I am using version 20.1.0.58


System.OutOfMemoryException:

   at Syncfusion.DocIO.DLS.FormatBase..ctor (Syncfusion.DocIO.Portable, Version=20.1200.0.58, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89)

   at Syncfusion.DocIO.DLS.FormatBase..ctor (Syncfusion.DocIO.Portable, Version=20.1200.0.58, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89)

   at Syncfusion.DocIO.DLS.CellFormat.GetDefComposite (Syncfusion.DocIO.Portable, Version=20.1200.0.58, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89)

   at Syncfusion.DocIO.DLS.FormatBase.get_Item (Syncfusion.DocIO.Portable, Version=20.1200.0.58, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89)

   at Syncfusion.DocIO.DLS.CellFormat..ctor (Syncfusion.DocIO.Portable, Version=20.1200.0.58, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89)

   at Syncfusion.DocIO.DLS.WTableCell.CloneCell (Syncfusion.DocIO.Portable, Version=20.1200.0.58, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89)

   at Syncfusion.DocIO.DLS.WCellCollection.CloneTo (Syncfusion.DocIO.Portable, Version=20.1200.0.58, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89)

   at Syncfusion.DocIO.DLS.WTableRow.CloneImpl (Syncfusion.DocIO.Portable, Version=20.1200.0.58, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89)

   at Syncfusion.DocIO.DLS.EntityCollection.CloneTo (Syncfusion.DocIO.Portable, Version=20.1200.0.58, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89)

   at Syncfusion.DocIO.DLS.WTable.CloneImpl (Syncfusion.DocIO.Portable, Version=20.1200.0.58, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89)

   at Syncfusion.DocIO.DLS.EntityCollection.CloneTo (Syncfusion.DocIO.Portable, Version=20.1200.0.58, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89)

   at Syncfusion.DocIO.DLS.WTextBody.CloneImpl (Syncfusion.DocIO.Portable, Version=20.1200.0.58, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89)

   at Syncfusion.DocIO.DLS.WSection.CloneImpl (Syncfusion.DocIO.Portable, Version=20.1200.0.58, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89)

   at Syncfusion.DocIO.DLS.EntityCollection.CloneTo (Syncfusion.DocIO.Portable, Version=20.1200.0.58, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89)

   at Syncfusion.DocIO.DLS.WordDocument.ImportContent (Syncfusion.DocIO.Portable, Version=20.1200.0.58, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89)


System.OutOfMemoryException:

   at System.IO.MemoryStream.ToArray (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)

   at Syncfusion.Compression.Zip.ZipArchiveItem.DecompressDataOld (Syncfusion.Compression.Portable, Version=20.1200.0.58, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89)

   at Syncfusion.Compression.Zip.ZipArchiveItem.DecompressData (Syncfusion.Compression.Portable, Version=20.1200.0.58, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89)

   at Syncfusion.XlsIO.Implementation.XmlSerialization.WorksheetDataHolder.ParseWorksheetData (Syncfusion.XlsIO.Portable, Version=20.1200.0.58, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89)

   at Syncfusion.XlsIO.Implementation.WorksheetImpl.ParseData (Syncfusion.XlsIO.Portable, Version=20.1200.0.58, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89)

   at Syncfusion.XlsIO.Implementation.XmlReaders.Excel2007Parser.ParseWorksheets (Syncfusion.XlsIO.Portable, Version=20.1200.0.58, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89)

   at Syncfusion.XlsIO.Implementation.XmlSerialization.FileDataHolder.ParseWorkbook (Syncfusion.XlsIO.Portable, Version=20.1200.0.58, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89)

   at Syncfusion.XlsIO.Implementation.XmlSerialization.FileDataHolder.ParseDocument (Syncfusion.XlsIO.Portable, Version=20.1200.0.58, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89)

   at Syncfusion.XlsIO.Implementation.WorkbookImpl.ParseExcel2007Stream (Syncfusion.XlsIO.Portable, Version=20.1200.0.58, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89)

   at Syncfusion.XlsIO.Implementation.WorkbookImpl.ParseStream (Syncfusion.XlsIO.Portable, Version=20.1200.0.58, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89)

   at Syncfusion.XlsIO.Implementation.WorkbookImpl..ctor (Syncfusion.XlsIO.Portable, Version=20.1200.0.58, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89)

   at Syncfusion.XlsIO.Implementation.ApplicationImpl.CreateWorkbook (Syncfusion.XlsIO.Portable, Version=20.1200.0.58, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89)

   at Syncfusion.XlsIO.Implementation.Collections.WorkbooksCollection.Open (Syncfusion.XlsIO.Portable, Version=20.1200.0.58, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89)

   at Syncfusion.XlsIO.Implementation.Collections.WorkbooksCollection.Open (Syncfusion.XlsIO.Portable, Version=20.1200.0.58, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89)

   at Syncfusion.XlsIO.Implementation.Collections.WorkbooksCollection.Open (Syncfusion.XlsIO.Portable, Version=20.1200.0.58, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89)


Attachment: Large_file_b48caa95.zip

15 Replies 1 reply marked as answer

AN Anto Nihil Sahaya Raj Syncfusion Team June 6, 2022 03:00 PM UTC

Hi Tuong,

Regarding DocIO - OutOfMemoryException in docx file:

We have tried to reproduce the mentioned “OutOfMemoryException” using the given document. But it works properly at our end. We suspect that, the exception might be occur due to your local machine reaches its peak memory while working with Word document.


Please find the details for “OutOfMemoryException”:
Essential DocIO keeps the entire document contents (paragraphs, images, tables and all other supported items along with the formatting) in main memory. Some documents may seem to have very less contents, but Essential DocIO uses more memory due to rich set of formatting applied to the contents. In case of opening a Docx file, you may think the file size is small but Essential DocIO utilizes very large memory. Whereas it is a zip archive file with extension “docx”, Essential DocIO internally decompress it and populate the content in the document object model utilizing remarkable main memory. The main memory utilized by an instance will not be released until the instance is removed from the document.

Hence there is a chance for “Out of memory exception” when the memory utilization exceeds the maximum level as the content of the document increases. This problem will not occur for all cases, it will vary for each case by case.

To resolve this problem, we recommend to use high configuration machines with extended RAM such as to create or open large size documents comfortably.


Regarding XlsIO - OutOfMemoryException in xlsx file:

The given Excel file contains the 500001 rows and 14 columns. To process this huge number of records it requires more than 1GB memory and minimum RAM as 8 GB.

Regards,
Anto Nihil S



TH Tuong Huynh June 10, 2022 04:41 AM UTC

Hi Anto Nihil S ,


I updated my server to 14GB RAM, but it still throws OutOfMemoryException, although the system is still not 100% memory.  

Need config anything on the server?

memory.png


Thanks & Regards,

Tuong 



AN Anto Nihil Sahaya Raj Syncfusion Team June 10, 2022 04:23 PM UTC

Hi Tuong,

Currently, we are checking the reported issue with high priority and will update you with more details on 13th June 2022.


Regards,
Anto Nihil S



AN Anto Nihil Sahaya Raj Syncfusion Team June 13, 2022 05:32 PM UTC

Hi Tuong,

Regarding DocIO - OutOfMemoryException in docx file:
We have tried to reproduce the reported problem using the given details, but it works properly at our end. For your reference, we have attached the sample application which we tried to reproduce the reported problem at our end. We suggest you to try the attached sample at your end.

Note: Please find the input Word document in “Data” folder of above sample location.

If you are still facing the same issue means, could you please share us the following details from your end.

1. Complete code example or runnable sample which used at your end
.
2. Details about your production environment (Operating system, RAM).

Based on the above details, we will try to replicate the same problem at our end and update you with the appropriate details.


Regarding XlsIO - OutOfMemoryException in xlsx file:
We suggest you to use ParseWorksheetsOnDemand option to reduce memory usage. Because, if the workbook contains multiple worksheets or more data in worksheets, then the parsing of the workbook will consume time and memory. ParseWorksheetsOnDemand of ExcelParseOptions can be used in Open method of IWorkbooks to parse the worksheet only when it is accessed.


Code Snippet:


IWorkbook workbook = application.Workbooks.Open(workbookStream, ExcelParseOptions.ParseWorksheetsOnDemand);


Kindly try the suggestion and let us know if this helps.


Regards,
Anto Nihil S



Attachment: ConsoleApp1_e3edd39b.zip


TH Tuong Huynh June 22, 2022 04:45 AM UTC

Hi Anto Nihil S,


Thanks for your help!


I am still facing this issue:

  1. I can reproduce it by the sample you sent if I change the platform target to x86 (if AnyCPU/x64, it works fine). Please refers to my video in the attachment.
  2. But on the server, although the platform is 64bit, it still throws OutOfMemory. (I used the Azure environment with 14GB RAM, and the ProcessorArchitecture is AnyCPU)

Regards,
Tuong

Attachment: OutOfMemory_bb4af662.zip


AN Anto Nihil Sahaya Raj Syncfusion Team June 22, 2022 03:10 PM UTC

Hi Tuong,

Currently, we are checking the reported issue with high priority and will update you with more details on tomorrow (23rd June 2022).

Regards,
Anto Nihil S



AN Anto Nihil Sahaya Raj Syncfusion Team June 23, 2022 03:52 PM UTC

Hi Tuong,

On further investigation, the 
DOCX document file size is 1 MB. If unzip the DOCX document, you can see the file size is 47 MB. While performing import content, it clones whole document and maintain all the instances in live, so it will take a considerable amount of memory. Currently, we are checking 
the reported problem in Azure. We will update the further details on 27th June 2022.

Please share us the following details which will be helpful to narrow down the problem and analyze the problem at our side

1. Azure type (web app service or function app)
2. RuntimeStack
3. Version
4. OS
5. Region
6. Plan


Regards,
Anto Nihil S



TH Tuong Huynh June 24, 2022 06:42 AM UTC

Hi Anto Nihil S,


Here are the server details:

1. Azure type: web app service

2. RuntimeStack: .NET

3. Version: .NET 6 (LTS)

4. OS: Windows

5. Region: Canada Central

6. Plan: Isolated (I3: 1)


Regards,

Tuong



AN Anto Nihil Sahaya Raj Syncfusion Team June 27, 2022 06:18 PM UTC

Hi Tuong,

Currently, we are investigating the reported problem and will update you with more details on 29th June 2022.

Could you please share your current app’s private memory consumption screenshot like below


Regards,
Anto Nihil S



TH Tuong Huynh June 28, 2022 09:04 AM UTC

Hi Anto Nihil S,


Here are the current app’s private memory consumption screenshots after processing the Large_file.docx:



Note: I downgraded the server to Plan: Isolated (I1: 1) which has 3GB of RAM. Because I saw the process stop at 68%, it can't use full RAM.


Regards,

Tuong



AN Anto Nihil Sahaya Raj Syncfusion Team June 29, 2022 04:45 PM UTC

Hi Tuong,

As we mentioned earlier, if unzip the DOCX document, the file size becomes 47 MB. So it takes more memory while performing import content. So we have suggested you to set the Azure app service platform as 64bit

Also while publishing the application, we suggest you set the target runtime as win-x64. You can see the below screenshot of how to set the target runtime as win-x64.



You can use the below code to check the
app’s current running process in Azure app service

if (System.Environment.Is64BitProcess)
{
throw new Exception("Running in 64 bit");
}


Note:
Uncomment the above code inside the attached application to check the app’s current running process whether 64bit or 32bit

For your reference, we have attached the sample application to check the 
app’s current running process in Azure app service

please let me know whether the issue is resolved or not at your side.

Regards,
Anto Nihil S


Attachment: AzureAppService_f8c85761.zip

Marked as answer

TH Tuong Huynh July 13, 2022 10:09 AM UTC

Hi Anto Nihil S,


I checked on my server, the Environment.Is64BitProcess = false. So my DevOps fixed it to true, then the system is not throwing OutOfMemory anymore. 


Note: Need to upgrade the RAM to be compatible with the file consumption.


Many thanks,

Tuong



SS Sooraj SAthish January 9, 2025 04:24 PM UTC

I am running docker on Linux machine on AWS. Running into OOM issue. Any help is deeply appreciated.

I am facing issue with XLSX files



SA Sivakumar Alagusundharam Syncfusion Team January 10, 2025 04:54 PM UTC

Hi Manik,

The corresponding team is currently validating the details of this problem. We will provide further updates on January 13, 2025.

Regards,
Sivakumar. A




DS Dharanya Sakthivel Syncfusion Team January 13, 2025 01:52 PM UTC

Manik,

Regarding “I am running docker on Linux machine on AWS. Running into OOM issue. Any help is deeply appreciated. I am facing issue with XLSX files”:
We have created a new forum thread to address this new issue. Kindly check the details at the link below:
Out of memory exception thrown When opening Xlsx File - Branched from 175452 | Syncfusion Forum Assist

Regards,
Dharanya.


Loader.
Up arrow icon