I created a Java Spring Boot application for a REST product catalog that gets it's info from a remote database where I only have access to a materialized view that rebuilds itself every day. It has a field with large images up to 5 megabytes long.
When I read this view in search for updates, I pass these images to my own system file (register the filename in my own db) but before it, I use Thumbnailator plugin to resize the images in two versions (thumb and fullscreen) with no more than 20 kilobytes each pair.
The problem is that during the process I receive a Java Heap Error:
java.lang.OutOfMemoryError: Java heap space
I tried to fix that using Slice class to paginate the view records (5 records at a time, with a for loop converting 1 file at a time), but no much better results achieved, so I searched a little more and saw this post where I should use -Xmx6g
when loading the JAR file, but it is not working either.
It seems that Java VM, Spring Framework, TomCat, (or my code), is not garbaging memory correctly.
I wish to know if there is a standard heap start and max value that could handle regular database and image processing without crashing; or if it is a known bug in one of those parts mentioned above.