Skip to content
Advertisement

Java heap space (java.lang.OutOfMemoryError)

In my project, I have a module to upload multiple image and create the thumbnails for it at once. For uploading, I am using JavaFX and for creating thumbnails, I am using Java.

I wrote upload code and call of thumbnail creation function inside a for loop. If the number of uploading images is more than five, I am getting this error:

Java heap space (java.lang.OutOfMemoryError)

I think, the code for uploading is fine, and the problem with thumbnail creation code. How can I solve this problem? How should I change the structure of my code ?

This is my JavaFX code:

JavaScript

Advertisement

Answer

You can try to use memory profilers to see which portion of code/class/method is consuming more memory. You can start with free JVisualVM or JConsole which comes with JDK.

Other well known profilers are:

-> Optimize IT

-> JProfiler

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement