2

I have a program running under a java wrapper, as the application has to be run as a Windows service. However, I am encountering Exception in thread "Thread-5" java.lang.OutOfMemoryError: Java heap space after running the application every couple of weeks.

The memory values are commented out. Does this mean there is no limit of memory this application is allowed to use?

I'm also checking the codes of possible memory leaks, but are there any ways to modify the config in order to find the cause/prevent out of memory errors?

#********************************************************************
# Wrapper Java Properties
#********************************************************************
# Java Application
#  Locate the java binary on the system PATH:
#wrapper.java.command=%JAVA_HOME%\bin\java
#  Specify a specific java binary:
set.JAVA_HOME=%JAVA_HOME%
wrapper.java.command=%JAVA_HOME%\bin\java

# Tell the Wrapper to log the full generated Java command line.
#wrapper.java.command.loglevel=INFO

# Java Main class.  This class must implement the WrapperListener interface
#  or guarantee that the WrapperManager class is initialized.  Helper
#  classes are provided to do this for you.  See the Integration section
#  of the documentation for details.
wrapper.java.mainclass=org.tanukisoftware.wrapper.WrapperSimpleApp

# Java Classpath (include wrapper.jar)  Add class path elements as
#  needed starting from 1
wrapper.java.classpath.1=../lib/wrapper.jar
wrapper.java.classpath.2=%JAVA_HOME%\lib\tools.jar
wrapper.java.classpath.3=C:\daifuku\wms\tomcat\webapps\wms\WEB-INF\classes
wrapper.java.classpath.4=C:\daifuku\wms\tomcat\webapps\wms\WEB-INF\lib\*.jar
wrapper.java.classpath.5=C:\daifuku\wms\tomcat\lib\comm.jar
wrapper.java.classpath.6=C:\daifuku\wms\tomcat\lib\servlet-api.jar
wrapper.java.classpath.7=C:\daifuku\wms\tomcat\lib\jsp-api.jar


# Java Library Path (location of Wrapper.DLL or libwrapper.so)
wrapper.java.library.path.1=%JAVA_HOME%\jre\lib

# Java Bits.  On applicable platforms, tells the JVM to run in 32 or 64-bit mode.
wrapper.java.additional.auto_bits=TRUE

# Java Additional Parameters
wrapper.java.additional.1=

# Initial Java Heap Size (in MB)
#wrapper.java.initmemory=64

# Maximum Java Heap Size (in MB)
#wrapper.java.maxmemory=512

# Application parameters.  Add parameters as needed starting from 1
wrapper.app.parameter.1=XXX

Many Thanks!

Wilson
  • 23
  • 3
  • The memory-parameters correspondent to the java-parameters -Xms and -Xmx. The default-values for those depend on the platform and other things. See https://stackoverflow.com/questions/14763079/what-are-the-xms-and-xmx-parameters-when-starting-jvm – Ralf Renz Jan 06 '20 at 10:24
  • I'm not posting this as an answer because I'm not sure what the wrapper equivalent is, but you'll want to look into the jvm setting '-XX:-HeapDumpOnOutOfMemoryError' as this will produce a heap dump when the OOM occurs that you can use to check where all space was used up at the time of the crash (I tend to import them into VisualVM to investigate). See https://www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html – user27158 Jan 06 '20 at 10:25

2 Answers2

2

Does this mean there is no limit of memory this application is allowed to use?

I believe that it will use the default value configured for your system: How is the default Java heap size determined?

Since you mentioned that the problem appears after running your application for a few weeks, most likely you have a memory leak. I advise you to make a dump using JvisualVm for your java wrapper process, and afterwards just analyze the dump using the Mat analyzer https://www.eclipse.org/mat/.

Vladucu Voican
  • 223
  • 1
  • 10
0

So you're basically asking which parameters for Heap does java actually allocate when you don't specify the init and max memory (which I believe translate to well known -Xmx and -Xms

In general its system dependent and the algorithm also has changed many times, so to be sure, you actually should check on your system:

java -XX:+PrintFlagsFinal -version | grep HeapSize // or run you application with that flag if you wish
// or on windows 
java -XX:+PrintFlagsFinal -version | findstr HeapSize

Then check for:

  • InitialHeapSize
  • MaxHeapSize
Mark Bramnik
  • 31,144
  • 4
  • 41
  • 69