Memory leak in Aspose.PDF.Cpp

Hi team,

I have created a server application that process the input pdf documents to html formats using Aspose.PDF.Cpp.
But, as more documents are processed, the application’s memory consumption continually increases. After processing approximately 10,000 PDF documents, the memory reaches up to 6GB.
I have to restart the server every time to free the memory.

After some testing, it appears that the memory leak originates from the Aspose library.

To confirm this, I used a simplified code to convert a single PDF to HTML and ran it through Valgrind to trace memory usage. The results indicate memory not being properly freed within the Aspose components.

I’m currently using Aspose.PDF.Cpp.25.1.Linux. I have tried updating to latest version, but the issue still exists.

Please refer to the atachments:
(sample code used for testing, input pdf and valgrind report)
aspose-memory.7z (127.1 KB)

Could you please help verify this issue, and advise any workarounds when using Aspose.PDF for C++ in long-running applications?

@vibhesh.patneedi

We are checking it and will get back to you shortly.

@vibhesh.patneedi
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): PDFCPP-3295

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

Hi Team,

Thank you for your response.

We’ve been regular users of your products and currently use Aspose.PDF and Aspose.Words for Java under a paid license. Due to high memory usage in our Java application, we began evaluating the C++ versions of these libraries as potential replacements.

However, during our testing, we encountered this memory leak.
We would greatly appreciate a quick resolution to this issue as it directly impacts our work and could potentially affect our client commitments.

Once the high memory usage is addressed, we will purchase the latest versions of Aspose.PDF and Aspose.Words for C++.

Thanks for your support.

Hi Team,

I’m following up on the issue regarding the memory leak in Aspose.PDF for C++ (Ticket ID: PDFCPP-3295). This issue continues to impact our workflow, and we would appreciate it if you could share an estimated time for the resolution.

Thanks

Hi @vibhesh.patneedi

We truly value you as a future customer and will do our best to resolve that issue immediately.
Unfortunately, I can not say the exact term, but it could be the nearest releases.
Thank you again for your interest!

Hi @vibhesh.patneedi,

My name is Ruslan, and I am currently responsible for identifying and resolving memory leaks within the Aspose.PDF.C++ product, as well as related sub-components.

Aspose.PDF.C++ is a sophisticated library that integrates over 24 Aspose sub-libraries. To support our debugging efforts, we utilize both standard diagnostic tools and a suite of specialized tools developed internally. These internal tools significantly accelerate the process of pinpointing problematic areas and determining the root causes of memory leaks.

I am actively working on the ticket and have already identified several memory leaks within some of the sub-libraries. I am in the process of addressing these issues.

Thank you for providing the code example - if I understand correctly, it represents a general use case of the Aspose.PDF.C++ library in your product. If you can share more details, it might be helpful.

Hi @ruslan.teliuk

Thanks for responding to the issue.

We’ve been long-time users of Aspose.Words and Aspose.PDF for Java (since version 20.5)
Since we are facing high memory usage with the application, we evaluated the C++ variants
and unfortunately, we encountered memory leaks in C++ too. This isn’t just limited to Aspose.PDF.CPP, the issue seems to extend to Aspose.Words.CPP as well.

Additionally, we noticed that the C++ versions are significantly slower than their Java counterparts. Upon further inspection, it appears that the Java libraries utilize multiple CPU cores effectively, while the C++ versions are primarily single-threaded, which could be the reason for performance difference.

Thanks in advance for your support.

@vibhesh.patneedi In Aspose.Words our main version of the product is .NET version and the code is written in C#. Then C# code is ported to Java and C++. Posting to Java is rather straightforward, since java and .NET have common main concept. With C++ the story is much more complicated especially with memory management. This is once of the reasons why C++ version does not have some features that are alailable in .NET version. For example loading PDF documents. If you encounter memory leaks in Aspose.Words, please report the problem in our support forum.
If your goal is to have better performance and memory management, I would recommend to stay with java version or consider using .NET version.

We have carefully analyzed the behavior of the provided code and, although there are cases where memory consumption increases, we did not manage to identify any actual memory leaks.

The issue seems to stem from the use of global static objects within the library—specifically, the font manager, which can accumulate information about used fonts. Over extended periods of use, this may indeed lead to gradual memory growth during the library’s operation.

We are currently exploring possible solutions to this problem, including more aggressive cache management or introducing a mechanism to clear unused data.
Thank you for pointing this out—it’s an important observation.