We’re running into memory problems when using Aspose.Words for .NET (version 21.5.0) to save big files to PDF format.
When converting bigger files like about 15mb, noticed that the memory went up to 1.5Gb and when we do multiple converts at a time it gets even worse.
There’s a memory leak when converting 2 large files at a time. The use case is, convert 1 file, memory goes up then convert another one at the same time, the memory ends up to be ~3gb. After the conversion completes, the memory went down to 1.5 and stayed there.
We have limited the file size to 50mb but it looks like we needed to lower this even more given the issues above.
Here’s how we implemented it:
public void Convert(Stream fileStream, Stream pdfFileStream, int maxPages)
{
var document = new Document(fileStream);
var pdfSaveOptions = new PdfSaveOptions
{
MemoryOptimization = true,
PageSet = new PageSet(
new PageRange(
0,
maxPages))
};
document.Save(pdfFileStream, pdfSaveOptions);
}
Please note that it is quite difficult to answer such questions because CPU performance and memory usage all depend on complexity and size of the documents you are loading/generating.
If you are loading huge Word documents into Aspose.Words’ DOM, more memory would be required. This is because during processing, the document needs to be held wholly in memory. Usually, Aspose.Words needs 10 times more memory than the original document size to build a DOM in the memory.
It hardly depends on local environment. It can be completely different for a server that generates thousands documents 24/7 or for a local PC that generate only the one document by demand.
We suggest you please use SaveOptions.MemoryOptimization property to optimize the memory performance. Setting this option to true can significantly decrease memory consumption while saving large documents at the cost of slower saving time.
We are already using SaveOptions.MemoryOptimization as written above. Tried setting it on and off, but still the memory consumption is 1gb+ for converting a 15mb file.
Upon debugging, it is indeed the load that’s taking so much memory. Just before save, the memory has already gone up, save was actually fast and only a little jump on memory.
It is the large text file that is causing the memory to shoot up to 1gb+
When the license is in trial/evaluation mode, loading the same large file and the conversion is pretty fast and the memory is only ~300mb, and probably because it just loaded and saved only the first 4 pages.
I wonder if the same behavior can be achieved with the Total License because we only need to load and save max of 100 pages.
We have tested the scenario with both documents using the latest version of Aspose.Words for .NET 21.8 at Windows 10, 16 GB RAM and have not faced the shared issue. So, please use the latest version of Aspose.Words.
Hi, I tested with the latest version of Aspose.Words and I still get 1GB+ memory when converting the Large Text File. May I know how you implemented it?
Please make sure that you are using the same document. Could you please share your working environment along with RAM status when you execute your application?
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
Enables storage, such as cookies, related to analytics.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.