Memory Requirements

Aspose.Words provides a wide range of features to work with documents in various formats. It is important to note that there is no limit on the maximum size of a document file that Aspose.Words can process or render. The only limitation is the amount of RAM (memory) available on your side.

How Much Memory Aspose.Words Needs

Usually Aspose.Words needs several times more memory than the document size to build a model of the document in memory. For example, if your document size is 1 MB, Aspose.Words needs 10-20 MB of RAM to build its Document Object Model (DOM) in memory. The multiplier depends on the format because some formats are more compact than others. For example, DOCX is more compact than DOC and RTF, and DOC is more compact than RTF.

There is no exact way to estimate how much memory Aspose.Words actually consumes during processing any particular document file. As you may know Java stores data in classes, each class instance uses some memory for JVM (Java virtual machine) internal purposes. So any paragraph or formatted text (even it consists of one character) takes some extra memory after loading into the DOM. Moreover, the Java garbage collector engine uses a complex algorithm to determine the best time to perform a memory collection, making it difficult to determine the real memory consumption.

How to Calculate the Amount of Memory

Let’s consider two documents:

  1. DOCX “A” document – 0.35 MB size (2 thousand pages), text only
  2. DOCX “B” document – 0.35 MB size (just 1 page), with PNG image inside

As you know, a lot of modern formats like DOCX, ODT, etc. are simple ZIP archives. So, we get the following calculation algorithm:

  1. Unzipping. Unzipped document “A” has 20 MB size, document “B” has 0.4 MB size
  2. Loading the document into the model (building its Document Object Model – DOM):
  • Creating DOM of the first document “A” requires 49 MB size
  • Creating DOM of the second document “B” requires just 2 MB size.
  1. Measuring the required amount of memory to render these documents to PDF. For this operation, Aspose.Words requires:
  • 294 MB for document “A”
  • 7 MB for document “B”

So, as you can see, there is no linear dependence on the input document size. There are many factors that can affect the required RAM size – the document format, its complexity and structure, the number of images and their format, and a lot of other factors.

How to Calculate the Memory Multiplier Most Accurately

Experiments with thousands of real documents shows that typically Aspose.Words requires several times more memory than the average document size to build a document model in memory and perform simple operations like conversion between flow formats, mail merge, parse, replace, and so on. Sometimes we are talking about a multiplier of 2, and sometimes 20.

More complex operations like rendering (converting to fixed page formats), updating fields, splitting page, and others, for some documents require 20 times more resources than the memory allocated by the document loaded in Aspose.Words DOM.

If your profiling results indicate a possible memory issue in Aspose.Words, please contact our Support Team and include all the diagnostic information.

See Also