Merger Memory issue

Hi: We have identified an excessive memory usage by Merger
when trying to merge files, we have identified that the function merger.save()
function is unable to process the data load and gives us a Java heap space error.

com.groupdocs.merger 24.2
java.version: 11

Error: java.lang.OutOfMemoryError: Java heap space
com.groupdocs.merger.internal.c.a.pd.ADocument.save(Unknown Source)

How does this function manage memory and what values are recommended?

Processed files:
6 files of 17.5 mb
Memory for Java
-Xms 512 mb
-Xmx 960 mb

The error was replicated in this code.
Source:
GroupDocs.Merger-for-Java-master-test.zip

@MTJames
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): MERGERJAVA-502

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.

1 Like

@MTJames

To address Java heap space issues when processing documents with images, it’s recommended to use the following JVM settings:

-Xms2G -Xmx5G

This configures the initial heap size to 2GB and the maximum heap size to 5GB, helping ensure stable operation of the API.

Hi @atir.tahir ,

Thanks for the answer, let me put more context on my question.

Our application is running on a container managed by kubernetes, we have setup memory limits on it, starting with 1gb to 1.5gb as limit.

Doing tests we realized that the process is not taking all available memory resources and throws the Java Space Error.

We would like to know the correct configs for our application, about your recommendation, what will be the right memory limits of our container? or how can we calculate this regarding the configs(-Xms2G -Xmx5G) that you proposed.

Regards

@MTJames

Thank you for providing the additional context. To better assist you with the issue you’re facing, we would appreciate if you could please provide the following information:

  1. Can you share the specific file(s) or example(s) that are causing the problem? It would be helpful to have the code or documents that are reproducing the issue.
  2. Regarding the memory limit on the container, you mentioned trying to lower the limits to -Xms1024m -Xmx1536m. Can you confirm if you have already tried this, and if so, did it help resolve the issue?
  3. If you are using your own files or custom code, could you please share the relevant code or documents? Having the specific implementation details will allow me to better understand and diagnose the problem.

Please let us know if you can provide any of these additional details. We’d be happy to take a closer look once we have more information about the files, examples, and code you are working with.

Looking forward to your response.

1 Like

Thanks for the help, the java configuration in the container has been revised, a parameter for memory management has been added and the API is working efficiently.
Thank you very much for your help

1 Like

@MTJames

You are welcome.