Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting java.lang.OutOfMemoryError : java Heap space on Jboss

Getting java.lang.OutOfMemoryError : java Heap space on Jboss 7 The entry in jboss configuration is

set "JAVA_OPTS=-Xms1G -Xmx2G -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=2096M"

The Error was

 java.lang.OutOfMemoryError: Java heap space
        at java.util.Arrays.copyOf(Arrays.java:3332) [rt.jar:1.8.0_231]
        at java.lang.AbstractStringBuilder.ensureCapacityInternal(AbstractStringBuilder.java:124) [rt.jar:1.8.0_231]
        at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:448) [rt.jar:1.8.0_231]
        at java.lang.StringBuffer.append(StringBuffer.java:270) [rt.jar:1.8.0_231]
        at java.io.StringWriter.write(StringWriter.java:112) [rt.jar:1.8.0_231]
        at java.io.PrintWriter.write(PrintWriter.java:456) [rt.jar:1.8.0_231]
        at java.io.PrintWriter.write(PrintWriter.java:473) [rt.jar:1.8.0_231]
        at java.io.PrintWriter.print(PrintWriter.java:603) [rt.jar:1.8.0_231]
        at java.io.PrintWriter.println(PrintWriter.java:756) [rt.jar:1.8.0_231]
        at java.lang.Throwable$WrappedPrintWriter.println(Throwable.java:765) [rt.jar:1.8.0_231]
        at java.lang.Throwable.printEnclosedStackTrace(Throwable.java:698) [rt.jar:1.8.0_231]
        at java.lang.Throwable.printEnclosedStackTrace(Throwable.java:710) [rt.jar:1.8.0_231]
like image 770
Rajeev Ranjan Avatar asked Dec 18 '22 14:12

Rajeev Ranjan


1 Answers

You are encountering OutOfMemoryError: Java heap space,in this case you dont have to increase MetaSpace. I will suggest you to increase heap allocation (Xms3G -Xmx3G). Make sure you have same values for Xms and Xmx. If you still encounter same issue with this then add -XX:+HeapDumpOnOutOfMemoryError option. This option will generate heap dump when OOM error occurs. You can analyze this heap dump through tools like eclipse mat to check which objects consume more memory and if there is any memory leak.

like image 173
Abhijit Humbe Avatar answered Mar 25 '23 09:03

Abhijit Humbe