Reputation: 4267
I'm having problem while trying to create a BufferedImage. I have this problem just on the server I rented, not on my development environment (my computer).
I have a form to upload image. After the image is uploaded I save it to the file system.
I save it immediately because, according to what some of you said, I can "release" resources from the server memory, since I use the image on my file system and not the object Part
to make the image resizes, controls, etc. I need.
As soon as I try to create a BufferedImage, from an image bigger than 2-3 mb, I get that error.
While executing this line my Application stop working and I get that error
BufferedImage immagineTemporaneaBufferizzata = ImageIO.read(new File...);
I used a method found on the internet to check the memory on the server. This is what I get before encountering the error:
Used Memory:26 Free Memory:30 Total Memory:57 Max Memory:57
Should I increase the heap memory? I tried to do it both on catalina.bat and catalina.sh but I didn't see changes in my Max Memory
. Probably I did something wrong. What's the right way to increase heap size on linux?
Upvotes: 1
Views: 1065
Reputation: 417452
Max memory 57 MB is frankly quite low for Java applications processing images with 2-3 MB. Yes, you should definitely increase the memory if you can.
To clarify: Image size 2-3 MB. What is this 2-3 MB? The size of the compressed image? If it is a JPG with 2-3 MB, that can be hell of a big image (depending on the quality). E.g. it might even be an image of 3200x2000 pixels which is 6.4 million pixels, and with 3 byte RGB pixel model it would be ~20 MB of binary data in memory.
About increasing tomcat memory see these questions:
Dealing with "java.lang.OutOfMemoryError: PermGen space" error
Increase Tomcat memory settings
Upvotes: 1