Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tomcat threw out "java.lang.OutOfMemoryError: Java heap space", but heap size in dump is less than -Xmx

Our tomcat server threw out "java.lang.OutOfMemoryError: Java heap space", but the heap size in dump file is only 1.7GB, and the -Xmx is 4GB.

I'm not sure what's happened, could you help me?

Environment: Redhat tomcat6 jdk6

like image 726
CQLI Avatar asked Oct 20 '22 11:10

CQLI


1 Answers

XmxSIZE can be greater then Java core dump because OutOfMemory happen when you try to allocate a large object!

Our application with -Xmx1000m and 670 MiB dump crashed by OutOfMemory on uploading 300 MiB attachment by a user.

We discover this in VisualVM in "Show Threads" trace on System.arrayCopy. Reference from local stack frame variable point to 300 MiB byte array.

Now we limit attachment size and save our application from future crashes.

like image 67
gavenkoa Avatar answered Oct 23 '22 10:10

gavenkoa