Modify jmeter memory configuration (win&mac&linux)

Table of contents

1. Background:

2. Modify jmeter memory in win environment

3. Modify jmeter memory in mac&linux environment

4. Verify whether the memory modification is successful


1. Background:

In the process of carrying out big data and high concurrency pressure testing , sometimes JMeter is stuck, making the test impossible. Viewing the log shows: java.lang.OutOfMemoryError: Java heap space

Reason: The memory of the running jmeter machine is high, exceeding the memory upper limit set by jmeter, and the memory overflows.

We need to configure enough memory for jmeter.

2. Modify jmeter memory in win environment

1. Find the jmeter installation path

You can go to the environment variable configuration file to view the installation location, or use the command

which jmeter

2. Modify the jmeter.bat file in the /apache-jmeter-5.4.3/bin/ directory

In jmeter.bat, this line

set HEAP=-Xms1g -Xmx1g -XX:MaxMetaspaceSize=256m

HEAP heap

-Xms: The heap memory initially allocated by the JVM. Indicates the size of the initial JAVA heap and the size of its exclusive JAVA heap when the process is just created. Once the object capacity exceeds the initial capacity of the JAVA heap, the JAVA heap will automatically expand to the size of -Xmx.

-Xmx: The maximum heap memory allowed by the JVM, allocated on demand. Indicates the maximum value that the java heap can expand to. In many cases, -Xms and -Xmx are usually set to be the same, because when the heap is not enough and the expansion occurs, memory jitter will occur and affect the stability of the program when it is running.

Here we set -Xms -Xmx to 1 g

MaxMetaspaceSize: The metadata area in jvm. Generally 256m is enough.

3. Modify jmeter memory in mac&linux environment

1. Find the jmeter installation path

You can go to the environment variable configuration file to view the installation location, or use the command

which jmeter

2. Modify the jmeter file in the /apache-jmeter-5.4.3/bin/ directory

HEAP heap:

-Xms: The heap memory initially allocated by the JVM. Indicates the size of the initial JAVA heap and the size of its exclusive JAVA heap when the process is just created. Once the object capacity exceeds the initial capacity of the JAVA heap, the JAVA heap will automatically expand to the size of -Xmx.

-Xmx: The maximum heap memory allowed by the JVM, allocated on demand. Indicates the maximum value that the java heap can expand to. In many cases, -Xms and -Xmx are usually set to be the same, because when the heap is not enough and the expansion occurs, memory jitter will occur and affect the stability of the program when it is running.

Here we set -Xms -Xmx to 1 g. Usually -Xms and -Xmx are set to be the same

MaxMetaspaceSize: The metadata area in jvm. Generally 256m is enough.

Put the jmeter file (not the jmeter.bat file), this line

: "${HEAP:="-Xms1g -Xmx1g -XX:MaxMetaspaceSize=256m"}"

Modify -Xms -Xmx

4. Verify whether the memory modification is successful

1. Restart jmeter after modification

2. Start jconsole to view the memory of jmeter

win starts jconsole:

Program Files\Java\jdk1.8.0_211\bin\jconsole.exe

Start jconsole on mac:

Enter jconsole directly in the terminal (forgot whether you need to configure the jconsole environment variable)

1. (Start jmeter first) and then start jconsole

2. Local process, select ApacheJMeter.jar

Choose an insecure connection

Select VM Profile

XX:MaxMetaspaceSize=1024m

 If the modified value is displayed here, the modification is successful.

Guess you like

Origin blog.csdn.net/qq_39208536/article/details/128917515
Recommended