Test2 new to fwq
1. Setting – XMS = – Xmx goes without saying
2. The initial heap memory allocated by the JVM is specified by – XMS, which is 1 / 64 of the physical memory by default; the maximum heap memory allocated by the JVM is specified by – Xmx, which is 1 / 4 of the physical memory by default. When the default free heap memory is less than 40%, the JVM will increase the heap to the maximum limit of – Xmx;
When the free heap memory is greater than 70%, the JVM reduces the heap to the minimum limit of – XMS. Therefore, the server generally sets -Xms and -Xmx equal so as to avoid adjusting the heap size after each GC.
Note: if – Xmx is not specified or specified too small, the application may cause java.lang.OutOfMemory Error, this error is from the JVM, not throwable and cannot be caught with try… Catch.
3. JVM memory limit (maximum)
First of all, the memory of the JVM is limited to the actual maximum physical memory. Assuming that the physical memory is infinite, the maximum memory of the JVM has a lot to do with the operating system. In short, although the controllable memory space of 32-bit processor is 4GB, the specific operating system will give a limit, which is generally 2gb-3gb (generally speaking, it is 1.5G-2G under Windows system and 2g-3g under Linux system), and there will be no limit for processors with more than 64bit.
Verification: use the Java – xmx512m – version command to test, and then gradually increase the value of 512. If the execution is normal, it means that the specified memory size is available, otherwise the error message will be printed,
No matter the real memory is 2G or 32g, jdk1.8.0 is used on 64 bit platform_ 101 and jdk1.8.0_ 141, the available values tested with the above commands are all over 700g. !
! [computer generated alternative text:
Java (TM) serentine environment (build1.8.e141-b15)
Javahotspot() 64 bitserver (build25 彐 41. Blmixedmode)
Youhavemaitin / var / spot / MAIT / root
##Specific operation examples:
Take an RPC service of our company as an example.
BTW: for the new service just launched, if you don’t know how much memory to set, you can set more memory first, and then analyze it according to the situation after GC.
The initial JVM memory parameter setting is: Xmx = 2G, XMS = 2G, XMN = 1g
Use jstat to view the current GC situation. As shown in the figure below: