Memory leak when using Document.compare

We’ve recently upgraded to version to 22.2 and started to get OutOfMemory errors when comparing documents. Even differences of 5 pages of text started to consume ~2GB of memory.

Example:

  • Document version 1 - empty document
  • Document version 2 - 160 pages of simple text
  • With version 21.3 - it consumes below 300MB of heap
  • With version 22.2 - getting OutOfMemory errors even with 10GB allocated.

Code fragment:

  Document doc1 = new Document(PATH_TO_V1);
  Document doc2 = new Document(PATH_TO_V2);

  CompareOptions compareOptions = new CompareOptions();
  compareOptions.setGranularity(Granularity.CHAR_LEVEL);

  doc1.compare(doc2, " ", Calendar.getInstance().getTime(), compareOptions);

Attaching example documents
versions.zip (19.2 KB)

@cernius Thank you for reporting this problem to us. For a sake of correction it has been logged as WORDSNET-23758. We will keep you informed and let you know once it is resolved.

@alexey.noskov Hi, any plans which release is going to include the fix?

@ginsep Unfortunately, the issue is not yet scheduled for development, so currently we cannot provide you any estimate. We will keep you informed and let you know once the issue is resolved.

The issues you have found earlier (filed as WORDSNET-23758) have been fixed in this Aspose.Words for Java 22.10 update also available on Maven.