Home > Back-end >  Server out of memory, a Java process to stop, how to avoid
Server out of memory, a Java process to stop, how to avoid

Time:11-20

Service and collapse last night, back on the server to start, have a hint of memory, the back is not a core business of module is turned off, can normal boot, but after a while and collapse, behind the originally need open 14 service only opened eight,
Want to ask everybody do you have any Suggestions,
Open Windows's own Perfmon performance monitoring can have what effect, is there any third party monitoring server plug-ins, such as I want to monitor the situation of the server,

CodePudding user response:

Analysis for memory code, can see the logic such as optimization of
You can use nmon monitoring

CodePudding user response:

Is that a server, a server launched eight service, also started too much,

CodePudding user response:

The Java virtual machine memory and no greater than the maximum server residual memory,
Dispatch server memory from 4 g to 2 g is ok, the application memory usage has maintained within 2 g () the end of the 2 g triggered when garbage collection, which will not lead to a total of memory to kill off the server process,

CodePudding user response:

refer to the second floor liuyh1024 response:
is a server, a server launched eight service, also started too much,

Yes, it is a 2 nuclear 16 gb server if all start tomcat has 14 service

CodePudding user response:

reference 1st floor shpery response:
analysis for memory code, can see the logic such as optimization of
Can use nmon monitoring

This is my current situation, the process of memory is one of the most TOMCAT so services occupy a total of 8 G

CodePudding user response:

The
reference 3 floor Jason Williams (????????????? ?). Response:
to the Java virtual machine memory and no greater than the maximum server residual memory,
Dispatch server memory from 4 g to 2 g is ok, the application memory usage has maintained within 2 g () the end of the 2 g triggered when garbage collection, which will not lead to a total of memory to kill off the server process,

Ok thank you I went to give it a try

CodePudding user response:

reference 4 floor qq_43396436 response:
Quote: refer to the second floor liuyh1024 response:
is a server, a server launched eight service, also started too much,

Yes a 2 nuclear 16 gb server if all start counting tomcat has 14 service


Invoke the JVM memory try, only one service so many services, server by?

CodePudding user response:

A server full service itself so much practice is wrong, no matter how old you memory, also can't so play, a hanging all hang a bit wonky...

CodePudding user response:

Suggest to add a server

CodePudding user response:

The
reference 3 floor Jason Williams (????????????? ?). Response:
to the Java virtual machine memory and no greater than the maximum server residual memory,
Dispatch server memory from 4 g to 2 g is ok, the application memory usage has maintained within 2 g () the end of the 2 g triggered when garbage collection, which will not lead to a total of memory to kill off the server process,

Bosses, how are you this adjustment, I have a lot of Java service and a tomcat, and adjust the server memory?

CodePudding user response:

Here in tomcat environment, for example, other WEB server, such as jboss, weblogic, etc is the same truth,

A, Java. Lang. OutOfMemoryError: PermGen space

PermGen space is the full name of Permanent Generation space, refers to the Permanent memory area,
This is mainly by the JVM memory storage Class and Meta information, when the Class was Loader will be put into PermGen space,
It and storage class Instance (Instance) Heap region is different, the GC (Garbage Collection) not in the main program running period of
PermGen space to clean up, so if there are a lot of CLASS in your application, you might appear PermGen space error,
The common errors in the web server to pre JSP compile, if you are under web APP with a large number of third-party jar, its size
More than the size of the JVM default (4 m) then can produce the error information,
The solution: manually MaxPermSize size
Suggestion: move the same third party jar file to the tomcat Shared/lib directory, so that we can achieve the goal of reducing jar files repeated memory,

Second, Java. Lang. OutOfMemoryError: Java heap space
Set the JVM Heap refers to the Java program is running process used to reach the JVM can allocate memory Settings. The JVM Heap size is automatically assigned at start-up time value,
Its initial space (Xms) is 1/64 of the physical memory, the largest space (-xmx) is a quarter of their physical memory, can make use of the JVM - Xmn - Xms -xmx options such as
Set, Heap size is the size of the Young Generation and Tenured Generaion, the sum of
Tip: in the JVM if 98% of the time is available for GC and Heap size less than 2% of the time will throw this exception information,
Biggest hint: Heap Size not more than 80% of the available physical memory, the general will - Xms and -xmx option is set to the same, while the Xmn for a quarter of the -xmx value,
The solution: manually Heap size

Linux modify the JVM memory size:

To add under tomcat bin catalina. Sh, position the cygwin=false, pay attention to quote with.
# OS specific support. $var must be set to either true or false.
JAVA_OPTS="- Xms256m - Xmx512m - Xss1024K - XX: XX: PermSize=128 m - MaxPermSize=256 m"
Cygwin=false



Under Windows to modify the JVM memory size:

Case 1: unzip version of Tomcat, through startup. Bat start Tomcat to load configuration

To add under tomcat bin catalina.
in the bat
Rem Guess the CATALINA_HOME if not defined
Set CURRENT_DIR=% % CD added later, red for the newly added.

Set JAVA_OPTS=- Xms256m - Xmx512m - XX: PermSize=128 m - XX: XX: MaxNewSize=256 m - MaxPermSize=256 m - Djava awt. Headless=true

Case 2: the installed version of Tomcat under no catalina. Bat

Windows service execution is bin/tomcat. Exe. He read the value in the registry, rather than the catalina. Bat Settings.

Modify the registry HKEY_LOCAL_MACHINE/SOFTWARE/Apache SOFTWARE Foundation/Tomcat Service Manager/Tomcat5/Parameters/JavaOptions
The original cost for the
- Dcatalina. Home="C:/ApacheGroup/Tomcat 5.0"
- Djava. Endorsed inside. Dirs="C:/ApacheGroup/Tomcat 5.0/common/endorsed inside"
- Xrs

Join - Xms300m - Xmx350m
Restart the tomcat service, set up effective

The proportion of each parameter:

-xmx and PermSize shall not exceed the JVM and the total memory available

PermSize cannot be greater than the -xmx

================

How to set up the Tomcat JVM virtual machine memory size

Can be set to the Java virtual machine to use memory, but if your choice is wrong, the virtual machine will not compensation, through the command line mode change the size of the virtual machine USES memory, shown in the table below, there are two parameters used to set the size of the virtual machine USES memory,
Parameter
Description
- Xms
Initialization JVM heap size
The -xmx
The maximum JVM heap
General according to the size of the two values need to be set up, initialize the size of the heap to perform virtual machine apply to the system at startup of the size of the memory, in general, this parameter is not important, but some applications in the case of large load will dramatically takes up more memory, this parameter is to is very important at this time, if the virtual machine startup Settings to use less memory and in this case, there are many object is initialized, the virtual machine must be used repeatedly increased memory to meet, for this reason, we usually set - Xms and -xmx to as big, and the maximum heap are limited by system using physical memory, usually with large amount of data the application range of sequence will use persistent objects, memory usage may increase rapidly, when the application needs to exceed the maximum heap memory when the virtual machine will prompt out of memory, and result in application service collapse, so big heap general advice the most value is set to 80% of the maximum available memory,
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related