we have an issue with a high memory usage from some documents. We are using Aspose.Net functions from a native Win32 application via CrossTalk (which allows usage of .Net libraries with Delphi). We are running this setup for almost two years now without having any issue like this before:
We have a document causing an exception in the Document constructor. Running the same document in a .Net environment only works without an exception but is also causing very high memory usage. The document has a file size of ~20MB, but loading the document via Aspose will require about 800+ MB:
image.png (9.5 KB)
This can be reproduced by running the following simple code:
var doc = new Document(@"S:\tmp\CAST EXCEPTION.doc");
I assume that the high memory usage is causing the problems inside our Win32 scenario. I wrote a little test tool to debug the scenario (for some reasons inside the test tool the exception only occurs with a very high memory load, in our real application we only have a basic memory usage of ~150 MB).
In Visual Studio you can set our test tool as host application which should be ran by the debugger, press the button and debug Exception while loading in the .Net library project:
image.png (17.6 KB)
I hope you can get us some help solving the problem. I attached you an archive including the document, a .net library project for reproduction and our delphi test tool (including its source codes). As the archive seems to be too big to be uploaded I uploaded it to one of our FTP servers and added you a file with a downloadlink. Please reply as soon as you have locally downloaded the document and projects so we can delete it from the FTP server.
download.zip (216 Bytes)
After an initial test with the licensed latest version of Aspose.Words for .NET i.e. 18.10 , we were unable to reproduce this issue on our end. We tested the following code on our end in a simple Visual Studio .NET console application:
// This line took 11290 ms to complete
Document doc = new Document("D:\\data_aspose\\CAST EXCEPTION.doc");
// This line took 24476 ms to complete
// PEAK MEMORY USAGE was 727 MB
See output: 18.10.pdf (3.3 MB)
Also, when clicking the ‘Button 1’ inside your ‘AsposeTestDelphiApp.exe’, it returned the following error:
thanks for your reply. Your observations are correct. I assume our problem is the peak memory usage of 727 MB. I assume that the error you (an we) observed from the Delphi app is a combination of our setup, which of course is a bit uncommon, and the high peak memory usage.
Maybe you can have a look into it if the memory usage can be reduced as this is a ~20 MB document only and neither MS needs much more than 100 MB of ram for its application when the document is loaded.
Regarding the exception message you can do the following, if you would like to analyze why this happens (I assume it is the high memory usage of that document):
- Open the Aspose.Wrapper.Demo.csproj class library project
- In debugging options, set the option to launch \bin\Debug\AsposeTestDelphiApp.exe
- Set a breakboint in DocumentWrapper.OpenDocument.
Start debugging and press the button in the delphi application, you than can see that the exception is thrown while calling the constructor.
I know that seems to be a special case for us but I would appreciate if your team may have a look into it and might be able to help us with the issue.
Otherwhise, is there maybe something weird inside the document itself which can be fixed to reduce the memory usage?
For the sake of any correction, we have logged this problem in our issue tracking system. The ID of this issue is WORDSNET-17623. We will further look into the details of this problem and will keep you updated on the status of this issue. We apologize for your inconvenience.
Thanks for having a look into it. Do you have saved the files locally so I can remove them from our ftp server?
Sure, you can remove those files from FTP server.
from the issue status I can see that the analysis is completed. Can you already give any feedback if there is something special with the one document itself or if we already can do something to improve performance?
Yes, the analysis of this issue is completed. Actually the source document is in DOCX format and it contains several very big EMF pictures with 200 Mb total size. EMF pictures have good compression rate that is why the DOCX has relatively small size. One solution we are thinking about is to try to hold the images compressed in memory and unpack on demand. We will inform you via this thread as soon as this issue is resolved. We apologize for any inconvenience.
Thanks for your feedback @awais.hafeez . May I ask if you can give an estimation if this will be implemented in the next Aspose 18.12 version? We need this information for our release planning.
I am afraid, there is no ETA (time frame) available at the moment. We will inform you via this thread as soon as any estimates or further updates are available. We apologize for your inconvenience.
The issues you have found earlier (filed as WORDSNET-16496) have been fixed in this update