Problem description:
1. java. Lang. outofmemoryerror: Java heap Space
JVM heap setting refers to the setting of memory space that JVM can allocate during Java program running. the JVM automatically sets the heap size value at startup. The initial space (-XMS) is 1/64 of the physical memory, and the maximum space (-xmx) is 1/4 of the physical memory. You can use options such as-xmn-XMS-xmx provided by JVM to set the configuration. The heap size is the sum of young generation and tenured generaion.
2. java. Lang. outofmemoryerror: permgen Space
The full name of permgen space is permanent generation space, which refers to the permanent storage area of the memory. This memory is mainly used by JVM to store class and meta information, when a class is loaded, it will be placed in the permgen space. It is different from the heap region where the class instance is stored. GC (garbage collection) permgen space is not cleaned up during the main program running period. Therefore, if your application contains many classes, the permgen space error may occur, this error is common when the web server pre-compile the JSP. If your web app uses a large number of third-party jar files and the size exceeds the default JVM size (4 MB), this error message is generated.
Solution:
1. modify memory settings in Linux
(1) Open the tomcat/bin/Catalina. Sh File
(2) Find the line # java_opts = "$ java_opts-dorg. Apache. Catalina. Security. securitylistener. umask = 'umask '".
(3) Delete the previous #
(4) Add "-xms512m"-xmx1024m "-server-XX: permsize = 128 M-XX: maxpermsize = 256m to the end of $ java_opts.
2. modify memory settings in Windows
(1) Open the tomcat/bin/Catalina. BAT file
(2) locate set java_opts = % java_opts % logging_config %.
(3) Replace % java_opts % with "-xms512m" "-xmx1024m"-server-XX: permsize = 128 M-XX: maxpermsize = 256 m
"-Xms512m" "-xmx1024m" indicates the initial value and maximum value of Java heap space.-server-XX: permsize = 128 M-XX: maxpermsize = 256m is the initial value and maximum value of permgen space.