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

Free Support Forum - aspose.com

Right way for destroy Aspose.Pdf.Document object

Hello, Aspose!

After inspecting Aspose docs for Aspose.Pdf.Document i find two methods that i can use for release memory.

  1. classic document.Dispose() method;
  2. special method document.FreeMemory() description from docs: “Clears memory”.

The question is: Should i call both methods when i want destroy document object (and order of calls, for example we call Dispose() first, after that we call FreeMemory())?
Or .Dispose() enough?

@mgkcortyw

Document.FreeMemory() just clears caches of objects for example cache of used pages etc. This may reduce memory consumption. This method was introduced in order to allow free allocated memory in critical situations. Normal work with document may be continued after FreeMemory() call i.e. it does not dispose or destroy anything critical. Just caches are cleared.

It is not required to call FreeMemory before Dispose, because cache will be destroyed anyway when document is disposed.