We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

OutOfMemoryException when saving large file as text

Using Aspose.Words .NET v20.12.0
The following code produces an OutOfMemoryException using a 60+MB text file:

LoadOptions options = new LoadOptions();
options.LoadFormat = LoadFormat.Text;
Document doc = new Document(filePath, options);
doc.Save(OutputFilePath, new TxtSaveOptions
  MemoryOptimization = true

Here is the stack: (weird symbols in source, see attached screenshot)

   at System.Text.StringBuilder.ToString()
   at ​  .​      (    )
   at    .       (    )
   at Aspose.Words.Document.(    )
   at Aspose.Words.Document.(Stream , String , SaveOptions )
   at Aspose.Words.Document.Save(String fileName, SaveOptions saveOptions)

image.png (5.8 KB)

@Buffer2018 Could you please attach the problematic document here? We will check it and provide you more information.
I have tested on my side with synthetically generated 300+MB text document and the document can be loaded and saved on my side without any issues. I have used the latest 22.1 version of Aspose.Words for .NET.

211228_01_BZLog.zip (2.3 MB)

Hello Alexey, the attached file causes an OutOfMemoryException with AsposeWords 20.12.0


@Buffer2018 I have tested your document with both 20.12 and the latest 22.1 versions of Aspose.Words for .NET. Both versions successfully open and save your document. The code you have provided is executed with about 15 seconds with both version of Aspose.Words on my side.
Could you please provide more information about your environment or maybe create a simple application that will allow us to reproduce the problem.

Very weird! I moved the relevant code to the top of our Main() function, just as a test - and it works well. When called in the original place, it throws an OutOfMemoryException. How do you suggest we investigate this? I cannot supply the source code for our entire app…

@Buffer2018 Please try reproducing the same call stack in a simple console application and attach this application here. We will investigate the issue and provide you more information. Unfortunately, it is difficult to say what is going wrong without ability to reproduce the issue.