Free Support Forum - aspose.com

Error in Aspose.Words


#1

we are receiving quite a few errors when attempting to generate a document with Aspose.Words. Have you seen anything like this stack trace? It is common across all of the errors we are seeing, and begins when we call the Save method on the Aspose.Words.Document class from our GenerateImage method:

System.ArgumentException: Parameter is not valid.
at System.Drawing.Graphics.CheckErrorStatus(Int32 status)
at System.Drawing.Graphics.DrawString(String s, Font font, Brush brush, RectangleF layoutRectangle, StringFormat format)
at System.Drawing.Graphics.DrawString(String s, Font font, Brush brush, Single x, Single y)
at .()
at . ​ ( )
at . ​ ( )
at . ​ ( )
at . ​ ( )
at . ​ ( )
at . ​ ( )
at . ​ ( )
at . ​ ( )
at . ​ ( )
at . ​ ( )
at . ​ ( )
at . ​ ( )
at . ​ ( )
at . ​ ( )
at . ​ ( )
at ​ . ​ ( )
at .( , Graphics )
at .( , Size )
at .()
at .(Stream )
at .(Stream )
at . ​ ( )
at . ​ ( )
at Aspose.Words.Document.( , SaveOptions )
at Aspose.Words.Document.(Stream , String , SaveOptions )
at Aspose.Words.Document.Save(Stream stream, SaveOptions saveOptions)
at (Object , Stream , SaveOptions )
at CheckFree.HF.ClubSoftware.CommonUI.DocumentView.GenerateImage(Document doc)


#2

I forgot to mention, we are using Aspose.Word for .Net, version 18.8


#3

@mdgumby

Thanks for your inquiry. Please ZIP and attach the following resources here for testing.

  • Input Word document.
  • Please create a standalone console application ( source code without compilation errors ) that helps us to reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we will start investigation into your issue and provide you more information.

Thanks for your cooperation.


#4

TestAspose.zip (4.8 MB)

it seems like there is possibly a memory leak with Aspose Words, or else I am not disposing of the Document object correctly.
attached is a zip file containing:

  • a test winforms app. It simply instantiates a Document object and then sets it to null
  • the test Word template doc file is in the bin\debug folder
  • also included is a screenshots folder containing screenshots of memory usage prior to instantiating the Document object, after instantiating, and after setting the object to null.

#5

@mdgumby

Thanks for sharing the detail. We have tested the scenario and have not faced any exception while using the latest version of Aspose.Words for .NET 19.1. So, please use Aspose.Words for .NET 19.1.

Regarding memory issue, you do not need to dispose any DOM object. When the document is closed, all the DOM data is purged from memory during the next garbage collector cycle. The memory may not be released until you close the application.


#6

using 19.1 did not solve the issue. I used Aspose.Words to create 2 documents. At the end of the process, I’m setting the Document object to null, and explicitly calling garbage collection. During this process, I ran Visual Studio 2017 analyzer and took several snapshots.The final snapshot was done after the second document was created, Document was set to null, and GC called. If you look at the heap details, you will see a significant number of Aspose objects still present.


#7

upload is not working (again)… how can I get the analyzer file (in a zip) to you for review?


#8

@mdgumby

Thanks for your inquiry. Objects will be cleaned up when they are no longer being used and when the garbage collector sees fit. Sometimes, you may need to set an object to null in order to make it go out of scope but overall there is usually no need to set to null. The call of GC does not help in some cases.

As shared in my previous post, when the document is closed, all the DOM data is purged from memory during the next garbage collector cycle. Please note that the memory may not be released until you close the application.


#9

this is a very long running application. so closing the application is not a viable option.


#10

@mdgumby

Thanks for your inquiry. Could you please share complete detail of your use case along with Visual Studio 2017 analyzer screenshots? We will then provide you more information about your query.


#11

As I mentioned in my previous reply, the upload capability is not working for me, so you need to provide me a different method for sending the analyzer report.


#12

if the upload actually worked, the zip contains a test app that simply opens an Aspose.Words document, sets it to null, and explicitly calls garbage collection.
there are screen shots from running using Aspose.Words version 11.8 vs running with Aspose.Words version 19.2. The analyzer screen shots should do a good job demonstrating the huge difference in memory use between the two.


#13

AsposeTesting.zip (860.1 KB)
this upload looks to have worked


#14

@mdgumby

Thanks for sharing the detail. We are investigating this issue and will get back to you soon.


#15

@mdgumby

Thanks for your patience. The issue you are facing is actually not a bug in Aspose.Words API.

Aspose.Words has some internal static objects which remain live after GC.Collect() because these static fields are GC roots. If you replace a call to Aspose.Words with a call to a class that has static members, you will see the same issue.