Fix java.lang.OutOfMemory Java Heap Space error in JDeveloper


Why out-of-memory error is thrown?

Permanent Generation: The Permanent Generation is where class files are kept. These are the result of compiled classes and JSP pages. If this space is full, it triggers a Full Garbage Collection. If the Full Garbage Collection cannot clean out old unreferenced classes and there is no room left to expand the Permanent Space, an Out‐of‐ Memory error (OOME) is thrown and the JVM will crash.


There are three basic JVM command switches that control the amount of memory in the Java heap.
-XX:Xms
-XX:Xmx
-XX:MaxPermSize

-XX:Xms used to set memory available to JVM initially.


-XX:Xms used to set maximum amount of memory into which the JVM can grow.


-XX:MaxPermSize are used to set size for Permanent Generation.



Fixing out-of-memory error 
  • Find the location of Oracle Middleware Home. Click here to see
  • Navigate to the location: <Oracle_Middleware_Home_Location>\jdev\bin and open the file jdev.conf 


  • Add the below two lines and comment the existing size of -XX:MaxPermSize by adding # in front of it like below:
#Commented

#AddVMOption  -XX:MaxPermSize=256M

# Set maximum size for Permanent Generation to 356 MB
AddVMOption  -XX:MaxPermSize=356M


AddVMOption -Doracle.ide.osgi.buddy.delegate.resource.exempt.paths=META-INF/services/javax.xml.ws.spi.Provider

# optimize the JVM for strings / text editing
AddVMOption -XX:+UseStringCache
AddVMOption -XX:+OptimizeStringConcat
AddVMOption -XX:+UseCompressedStrings

# if on a 64-bit system, but using less than 32 GB RAM, this reduces object pointer memory size
AddVMOption -XX:+UseCompressedOops

# use an aggressive garbage collector (constant small collections)
AddVMOption -XX:+AggressiveOpts

# for multi-core machines, use multiple threads to create objects and reduce pause times
AddVMOption -XX:+UseConcMarkSweepGC
  • Navigate to the location: <Oracle_Middleware_Home_Location>\ide\bin and open the file ide.conf 

  • Add the below lines and comment the existing size of -XX:Xms and  -XX:Xmx by adding # in front of it like below:
#Commented
#AddVMOption  -Xmx640M
#AddVMOption  -Xms128M

#Set max heap size to 940 MB
AddVMOption  -Xmx940M

#Set initial heap size to 128 MB
AddVMOption  -Xms128M

  • Save the files and restart the jDeveloper. If you still get the out-of-memory error, then increase the size of Xmx parameter

Comments