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

Free Support Forum - aspose.com

com.aspose.pdf.kit.PdfContentEditor Memory Leak

We're using com.aspose.pdf.kit.PdfContentEditor.replaceText("someString","someString") and experiencing a memory leak with com.aspose.pdf.kit.lj

The heap dump is below for reference. Please let me know if anyone has seen this before and if this is a known problem thats fixed in a later version or hot fix.

The class "com.aspose.pdf.kit.lj", loaded by"org.jboss.modules.ModuleClassLoader @ 0xaf1adad0", occupies 994,780,440 (87.92%) bytes. The memory is accumulated in one instance of "java.lang.Object[]"loaded by ""


Hi Darren,

Thanks for contacting support.

Please share the resource PDF files causing this problem so that we can test the scenario at our end. We are sorry for this inconvenience.


I've attached the pdf that we're using. If you run a replaceText against one of the token fields (for example PdfContentEditor.replaceText("[CustomerFirstName]","John"); in a loop a few hundred times you should see the memory leak after taking a head dump and using a memory analyzer tool. The suspect area at this point is a static ArrayList in one of aspose classes (com.aspose.pdf.kit.ll).

Thanks, Darren

Hi, Looking for an update on this and if you can recommend anything. This is a production problem in our environment at this point and anything you can recommend to resolve this problem ASAP is greatly appreciated.

Hi Darren,

Thanks for sharing the resource file.

I have tested the scenario using latest release of Aspose.Pdf for Java 9.1.0 where I have used the following code snippet based on new Document Object Model (DOM) of com.aspose.pdf package and I am unable to notice any problem. Please note that Aspose.Pdf.Kit for Java has been discontinued as a separate product and all its classes and enumerations are merged under com.aspose.pdf.facades package of Aspose.Pdf for Java.

Therefore we recommend you to please try using the latest release of autoported mergedAPI of Aspose.Pdf for Java. Please note that DOM of com.aspose.pdf package is latest and recommended approach as compared to legacy Aspose.Pdf.Kit for Java.


for(int counter =1;
counter<=100; counter++)<o:p></o:p>


// Open document

com.aspose.pdf.Document pdfDocument = new com.aspose.pdf.Document("c:/pdftest/Cover+Letter+in+PDF.pdf");

// Create TextAbsorber object to find all instances of the input search phrase

com.aspose.pdf.TextFragmentAbsorber textFragmentAbsorber = new com.aspose.pdf.TextFragmentAbsorber("CustomerID");

// Accept the absorber for first page of document


// Get the extracted text fragments into collection

com.aspose.pdf.TextFragmentCollection textFragmentCollection = textFragmentAbsorber.getTextFragments();

// Loop through the fragments

for(com.aspose.pdf.TextFragment textFragment : (Iterable)textFragmentCollection)


// Update text and other properties





// Save the updated PDF file



We have not tried the new API yet, but it does appear that using the new API could potentially work for us. It will require some significant coding changes to our already production code and we would have to incur significant costs to move those changes through our delivery process. Before moving forward with any of this I need to understand licensing. We paid for a license a few years back and now if we move to this new API how will this impact our current license?

thanks<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Hi Darren,

Please note that recently we have published Aspose.Pdf for Java 9.3.0 and we recommend you to please try using the latest release. Now concerning to the license related query, please open the license file in notepad and check 20131220 tag. If the product release date is after license expiry date, then you will have to update your license subscription.

Hi Darren,

In addition to Nayyer reply. As you stated you have purchased license few year back, most probably it would has been expired. You may renew your existing subscription for another year and can get 40% of current product price as discount. Please visit Renewal policies page for details,

Moreover, in reference to memory leak issue. Please note that after completing operations with Aspose.Pdf object it needs to close it with close() or dispose() methods and finally use com.aspose.pdf.MemoryCleaner.clear() method, introduced in Aspose.Pdf for Java 9.3.0. It clears Aspose.Pdf specific instances. It will enables you to effective memory usage.

Please feel free to contact us for any further assistance.

Best Regards,