Using Jmeter for stress testing will encounter a memory overflow error after a period of time, causing Jmeter to freeze. This is because the default HEAP configuration of Jmeter is too small. The solution is as follows:
1. Windows environment
Modify jmeter.bat, the following two lines:
set HEAP=-Xms512m -Xmx512m
set NEW=-XX:NewSize=128m -XX:MaxNewSize=128m
Change it to:
set HEAP=-Xms512m -Xmx1024m
set NEW=-XX:NewSize=128m -XX:MaxNewSize=1024m
According to experience: HEAP can be set to half of the physical memory at most. If the HEAP exceeds half of the physical memory, it will cause Jmeter to run slowly or even overflow the memory. The reason is that Java eats more memory and occupies CPU.
Note: The Xms of a JDK32-bit computer cannot exceed 1500M, and the maximum is 1378M, otherwise an error will be reported when starting Jmeter.
2. Linux environment
Modify jmeter.sh:
java $JVM_ARGS -Xms1G -Xmx5G -XX:MaxPermSize=512m -Dapple.laf.useScreenMenuBar=true -jar `dirname $0`/ApacheJMeter.jar "$@"
3. Check the JDK bits
If the JDK is 64-bit, the last line will display 64-Bit, if not, it is 32-bit.