Dockerized spring boot app - OutOfMemoryError: Java heap space

spring boot application
maven build tool
aspose total (currently, trial edition)

The application takes pdf, word, excel and image files and converts them to .tiff. The java code for the converters is really simple so i doubt it will be a code problem.
The converter is executed using an http endpoint.

The application is deployed for testing in a linux vm using docker. I’m using “openjdk:11” as base image. The slim edition caused errors (related to fonts i think).

I’m using some test files as input and until now i have found the following cases in which the application fails to convert some files:

  1. Pdf to tiff conversion when the application receives 2 requests to convert 2 different pdf files to tiff.
    The request are sent about the same time using Postman, that is, the are two conversion processes
    run at the same time. This causes the following problem:

java.lang.OutOfMemoryError: Java heap space

[994.979s][warning][gc,alloc] http-nio-8080-exec-10: Retried waiting for GCLocker too often allocating 3210508 words
[994.991s][warning][gc,alloc] http-nio-8080-exec-10: Retried waiting for GCLocker too often allocating 4348682 words
2022-04-14 15:54:04.305 ERROR 1 — [io-8080-exec-10] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Handler dispatch failed; nested exception is java.lang.OutOfMemoryError: Java heap space] with root cause

As a result, one pdf file may not be converted successfully.

PS The files get converted successfully and the application doesn’t throw an exception if i convert
them one by one

  1. Same case for the doc/docx to tiff converter.
    Running two conversion processes at the same time causes:

2022-04-15 14:49:44.305 ERROR 1 — [nio-8080-exec-9] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Handler dispatch failed; nested exception is java.lang.OutOfMemoryError: Java heap space] with root cause

java.lang.OutOfMemoryError: Java heap space

PS The files get converted successfully and the application doesn’t throw an exception if i convert
them one by one

  1. Same case as 2) but for some reason i have got also this output (i didn’t change the code):

2022-04-15 15:14:01.230 ERROR 1 — [io-8080-exec-10] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Handler dispatch failed; nested exception is java.lang.OutOfMemoryError: Java heap space] with root cause

java.lang.OutOfMemoryError: Java heap space
at java.desktop/java.awt.image.DataBufferInt.(DataBufferInt.java:75) ~[na:na]
at java.desktop/java.awt.image.SinglePixelPackedSampleModel.createDataBuffer(SinglePixelPackedSampleModel.java:242) ~[na:na]
at java.desktop/java.awt.image.Raster.createWritableRaster(Raster.java:1005) ~[na:na]
at java.desktop/java.awt.image.BufferedImage.getData(BufferedImage.java:1422) ~[na:na]
at javax.media.jai.RenderedImageAdapter.getData(RenderedImageAdapter.java:153) ~[jai-core-1.1.3.jar!/:na]
at com.sun.media.jai.codecimpl.TIFFImageEncoder.encode(TIFFImageEncoder.java:180) ~[jai-codec-1.1.3.jar!/:na]
at com.sun.media.jai.codecimpl.TIFFImageEncoder.encode(TIFFImageEncoder.java:137) ~[jai-codec-1.1.3.jar!/:na]
at com.aspose.words.internal.zzXlK.zzWPL(Unknown Source) ~[aspose-words-21.10-jdk17.jar!/:21.10.0]
at com.aspose.words.internal.zzXlK.zzWun(Unknown Source) ~[aspose-words-21.10-jdk17.jar!/:21.10.0]
at com.aspose.words.internal.zzZ23.zzWun(Unknown Source) ~[aspose-words-21.10-jdk17.jar!/:21.10.0]
at com.aspose.words.zzXBm.zzhl(Unknown Source) ~[aspose-words-21.10-jdk17.jar!/:21.10.0]
at com.aspose.words.zzXBm.zzWPL(Unknown Source) ~[aspose-words-21.10-jdk17.jar!/:21.10.0]
at com.aspose.words.zzyR.zzWPL(Unknown Source) ~[aspose-words-21.10-jdk17.jar!/:21.10.0]
at com.aspose.words.Document.zzD8(Unknown Source) ~[aspose-words-21.10-jdk17.jar!/:21.10.0]
at com.aspose.words.Document.zzWPL(Unknown Source) ~[aspose-words-21.10-jdk17.jar!/:21.10.0]
at com.aspose.words.Document.save(Unknown Source) ~[aspose-words-21.10-jdk17.jar!/:21.10.0]
at eu.company.asposeconverter.converter.WordToTiffConverter.runConverter(WordToTiffConverter.java:33) ~[classes!/:0.0.1-SNAPSHOT]
at eu.company.asposeconverter.service.AsposeService.convert(AsposeService.java:40) ~[classes!/:0.0.1-SNAPSHOT]
at eu.company.asposeconverter.controller.AsposeController.convert(AsposeController.java:26) ~[classes!/:0.0.1-SNAPSHOT]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205) ~[spring-web-5.3.17.jar!/:5.3.17]
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:150) ~[spring-web-5.3.17.jar!/:5.3.17]
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:117) ~[spring-webmvc-5.3.17.jar!/:5.3.17]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895) ~[spring-webmvc-5.3.17.jar!/:5.3.17]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808) ~[spring-webmvc-5.3.17.jar!/:5.3.17]
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ~[spring-webmvc-5.3.17.jar!/:5.3.17]
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1067) ~[spring-webmvc-5.3.17.jar!/:5.3.17]
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:963) ~[spring-webmvc-5.3.17.jar!/:5.3.17]
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) ~[spring-webmvc-5.3.17.jar!/:5.3.17]

  1. Running only one conversation process at a time will output the same as in case 2)
    when i provide two specific doc files as input.

What should i do either to the spring boot application or the docker image/container?

In the production environment the application should be able to accept about 6-8 requests for conversion at the same time!

@stsakas

To ensure a timely and accurate response, please attach the following resources here for testing:

  • Your input Word, PDF, and Excel documents.
  • Please create a simple Java application (source code without compilation errors) that helps us to reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we will start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip and upload them.