我在升级了8GB到16GB的RAM后,仍然遇到了JMeter的内存溢出错误。

huangapple go评论64阅读模式
英文:

I am getting JMeter Out of Memory error even after I already upgraded my RAM from 8G to 16G

问题

以下是翻译好的内容:

请问有人能帮助我解决在运行 JMeter 时遇到的 内存不足(OOM)错误吗?

我是 Java 和 JMeter 的新手,也是性能测试方面的初学者。我使用了命令提示符,但仍然遇到了 内存不足 的问题。我尝试调整了堆大小,但每次更改后运行都没有继续进行。

我的当前堆大小如下:

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

我又增加了内存:从 8GB,我的内存现在是 16GB
但当我再次使用 1000个线程 运行它时,会显示下面的错误:

Uncaught Exception java.lang.OutOfMemoryError: unable to create new native thread in thread Thread[Thread Group 1-130,5,main]. See the log file for details.
Uncaught Exception java.lang.OutOfMemoryError: unable to create new native thread in thread Thread[Thread Group 1-63,5,main]. See log file for details.
Uncaught Exception java.lang.OutOfMemoryError: unable to create new native thread in thread Thread[Thread Group 1-135,5,main]. See log file for details.
Uncaught Exception java.lang.OutOfMemoryError: unable to create new native thread in thread Thread[Thread Group 1-19,5,main]. See log file for details.
#
# Java 运行时环境内存不足,无法继续运行。
# 本机内存分配(malloc)无法为 ChunkPool::allocate 分配 32756 字节

有时我也会遇到仅出现以下错误:

# Java 运行时环境内存不足,无法继续运行。
# 本机内存分配(malloc)无法为 ChunkPool::allocate 分配 32756 字节

请问有人能帮助我吗?我只是一个初学者,如果您回复时不要使用过于技术性的术语,我会非常感激。

提前谢谢您。

英文:

Can someone please help me with the Out of Memory (OOM) error that I encountered while running JMeter

I am a newbie in Java and in JMeter, and also in performance testing. I used the command prompt but I am still encountering Out of Memory issue. I tried to adjust the heap size but running did not continue every time I change it.

My current heap size is below

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

I added another memory: from 8GB, my memory is now 16GB.
But when I run it again with 1000 threads, the error below is shown:

Uncaught Exception java.lang.OutOfMemoryError: unable to create new native thread in thread Thread[Thread Group 1-130,5,main]. See the log file for details.
Uncaught Exception java.lang.OutOfMemoryError: unable to create new native thread in thread Thread[Thread Group 1-63,5,main]. See log file for details.
Uncaught Exception java.lang.OutOfMemoryError: unable to create new native thread in thread Thread[Thread Group 1-135,5,main]. See log file for details.
Uncaught Exception java.lang.OutOfMemoryError: unable to create new native thread in thread Thread[Thread Group 1-19,5,main]. See log file for details.
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (malloc) failed to allocate 32756 bytes for ChunkPool::allocate

Sometimes I am also encountering just this error:

# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (malloc) failed to allocate 32756 bytes for ChunkPool::allocate

Can someone please help me. I am just a beginner so I would appreciate if you will reply with terms that are not too technical.

Thank you in advance.

答案1

得分: 1

你所遇到的错误表明底层的操作系统无法创建新的本地线程/进程。

  1. 尝试增加操作系统的限制,例如,如果你使用的是Linux,你可以使用ulimit -n命令来检查最大线程数。
  2. 在任何情况下,你都可以通过-Xss JVM参数来减少堆栈大小。

不幸的是,根据当前的描述,你的问题没有提供足够的信息以便得出全面的答案。如果上述提示没有帮助,考虑添加更多细节,例如:

  • 操作系统版本和架构
  • JMeter版本
  • Java版本和架构
  • .HPROF文件的前20行内容

同时,确保遵循来自《JMeter负载测试“内存不足”失败的9种简单解决方案》文章中的建议。

英文:

The error you're getting indicates that underlying operating system is not able to create a new native thread / process.

  1. Try increasing limits for the operating system, i.e. if you're on Linux you can check the maximum number of threads using ulimit -n command
  2. In any case you can decrease the stack size via -Xss JVM argument

Unfortunately in its current shape your question doesn't provide enough information in order to come up with a comprehensive answer, if above hints don't help consider adding more details like:

  • Operating system version and architecture
  • JMeter version
  • Java version and archivecture
  • At least first 20 lines of the .HPROF file

Also make sure to follow recommendations from the 9 Easy Solutions for a JMeter Load Test “Out of Memory” Failure article

答案2

得分: 0

the flag Xmx indicates the maximum memory for the JVM. You should increase your xmx value to something more appropriate for your usage.

try:

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

英文:

the flag Xmx indicates the maximum memory for the JVM. You should increase your xmx value to something more appropriate for your usage.

try:

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

答案3

得分: 0

更改 jmeter.sh 文件中的堆大小,如果您使用的是 Linux/Ubuntu,则修改 Jmeter.bat 文件(如果是 Windows 系统)。将 -Xmx1g 增加到系统内存的一半,例如 4GB(-Xmx4g)。还尝试将用户负载从 500 增加,并在 Windows 的任务管理器中检查 CPU 和 RAM 利用率。

英文:

change Heap size in jmeter.sh file if you are using Linux/ubuntu, Jmeter.bat in windows. Increase the -Xmx1g =to half of the memory of the system i.e., 4gb(-Xmx4g). also try to increase the user load from 500 and check the CPU and RAM utilization in Task Manager of Windows.

答案4

得分: 0

我曾在尝试在8GB RAM中运行1万个虚拟用户时遇到了内存不足的问题。后来将实例内存增加到16GB,成功地运行了1万个虚拟用户的负载。

  1. /etc/profile/ 中将JVM内存增加为12GB。

  2. 在 "jmeter" 文件(Linux操作系统)中将JMeter堆大小增加为10GB。 (对于Windows服务器,在 "jmeter.bat" 文件中有 "set HEAP" 选项)

  3. 打开文件限制 - 65535

  4. 最大用户进程限制 - 65535


以 root 用户身份打开命令窗口
执行以下命令并更新值以更改默认限制

  1. vim /etc/security/limits.conf

root soft nproc 65535
root hard nproc 65535
root soft nofile 65535
root hard nofile 65535

  1. vim /etc/sysctl.conf

fs.file-max = 65535

sysctl -p

  1. reboot

重启后,更改将影响计算机,并请确认交叉验证。

应该以 root 用户身份在非GUI模式下运行 JMeter 脚本。

注意:如果有的话,在 "bin" 文件夹中删除转储堆文件。

英文:

I have faced the out of memory issue on trying to run 10k vusers in 8GB RAM. Later on increased the instance memory as 16GB and 10k vusers load ran successfully.

  1. Increase JVM memory as 12 GB in /etc/profile/

  2. Increase JMeter Heap as 10GB in "jmeter" file(Linux OS). ('set HEAP' option is available in "jmeter.bat" file for Windows server)

3.Open files limit - 65535

  1. maximum user process limit - 65535

Open the command window as root user
Execute following commands and update values to change the default limit

  1. vim /etc/security/limits.conf

root soft nproc 65535
root hard nproc 65535
root soft nofile 65535
root hard nofile 65535

  1. vim /etc/sysctl.conf

fs.file-max = 65535

sysctl -p

  1. reboot

After rebooting, the changes will be affected in the machine and kindly cross verify that.

Should run the JMeter script in Non-GUI as a root user only.

Note: Delete dump heap file in "bin" if any.

huangapple
  • 本文由 发表于 2020年3月16日 14:31:57
  • 转载请务必保留本文链接:https://go.coder-hub.com/60701312.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定