微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

JMeter – Linux上的内存不足

我正在尝试运行应用程序的负载testing。 为此,我在Ubuntu Vm上使用JMeter(v.2.13),内存为60GB,cpu功率也足够多。 目标是达到10k用户通过WebSocket连接。

但是在testing运行期间,我在ssh-console上得到了以下错误(大约1.5k到2.5k的模拟用户

OpenJDK 64-Bit Server VM warning: Attempt to protect stack guard pages Failed. OpenJDK 64-Bit Server VM warning: Attempt to deallocate stack guard pages Failed. OpenJDK 64-Bit Server VM warning: INFO: os::commit_memory(0x00007f20ee653000,12288,0) Failed; error='Cannot allocate memory' (errno=12) # # There is insufficient memory for the Java Runtime Environment to continue. # Native memory allocation (malloc) Failed to allocate 12288 bytes for committing reserved memory. # An error report file with more @R_698_4045@ion is saved as: # /jmetertests/jm/bin/hs_err_pid1833.log OpenJDK 64-Bit Server VM warning: Attempt to deallocate stack guard pages Failed. OpenJDK 64-Bit Server VM warning: INFO: os::commit_memory(0x00007f2218de8000,0) Failed; error='Cannot allocate memory' (errno=12)

提到的错误报告文件看起来像这样

# There is insufficient memory for the Java Runtime Environment to continue. # Native memory allocation (malloc) Failed to allocate 12288 bytes for committing reserved memory. # Possible reasons: # The system is out of physical RAM or swap space # In 32 bit mode,the process size limit was hit # Possible solutions: # Reduce memory load on the system # Increase physical memory or swap space # Check if swap backing store is full # Use 64 bit Java on a 64 bit OS # Decrease Java heap size (-Xmx/-xms) # Decrease number of Java threads # Decrease Java thread stack sizes (-Xss) # Set larger code cache with -XX:ReservedCodeCacheSize= # This output file may be truncated or incomplete. # # Out of Memory Error (os_linux.cpp:2798),pid=1833,tid=140472285792000 # # JRE version: OpenJDK Runtime Environment (7.0_75-b13) (build 1.7.0_75-b13) # Java VM: OpenJDK 64-Bit Server VM (24.75-b04 mixed mode linux-amd64 ) # Derivative: IcedTea 2.5.4 # distribution: Ubuntu 14.04 LTS,package 7u75-2.5.4-1~trusty1 # Failed to write core dump. Core dumps have been disabled. To enable core dumping,try "ulimit -c unlimited" before starting Java again

我尝试通过在.sh-file中发出java命令之前添加以下行来修改jmeter.sh来分配更多内存:

我如何使用基地址来获得dynamic?

OOM杀手(内存不足)与大量的内存(?!) – inotify

Linux内存pipe理开销

cudaHostRegister是否等同于mlock()系统调用

如何使.NET应用程序“大地址感知”?

JVM_ARGS="-xms5g -Xmx20g -Xss300k"

我也尝试用下面的命令设置_JAVA_OPTIONS环境variables

export _JAVA_OPTIONS="-xms5g -Xmx20g"

最后我发现这个命令是一些SO线程

sysctl -w vm.max_map_count=500000

top命令给我下面的内存信息

KiB Mem: 61836576 total,15163400 used,46673176 free,10636 buffers KiB Swap: 0 total,0 used,0 free. 94492 cached Mem

UPDATE

仅供参考:除了简单的数据编写器之外,我不使用JMeter中的任何监听器。 不过,即使我禁用最后一个监听器,也会引发错误

java -xms40g -version

是成功的 – 所以我可以真的分配这么多的内存

我通过使用减小了堆栈大小

-Xss300k

这至less帮助我改变了一些事情

Uncaught Exception java.lang.OutOfMemoryError: unable to create new native thread. See log file for details.

错误。 似乎系统上的线程数量已经耗尽?

UPDATE2

如某些用户所要求的结果uf ulimit -a

core file size (blocks,-c) 0 scheduling priority (-e) 0 pending signals (-i) 491456 max locked memory (kbytes,-l) 64 open files (-n) 500000 pipe size (512 bytes,-p) 8 POSIX message queues (bytes,-q) 819200 real-time priority (-r) 0 stack size (kbytes,-s) 8192 max user processes (-u) 491456 ... all other entries are set to 'unlimited'

而limits.conf包含以下条目

* hard nofile 900000 * soft nofile 900000 root hard nofile 900000 root soft nofile 900000

另外我已经把proc/sys/kernel下的threads-max设置为荒谬的高,并且增加了proc/sys/vm/max_map_count

我错过了什么,或者我做错了什么? 感谢您的帮助。

Linux中的select性核心转储 – 如何select转储的部分?

caching在Linux服务器上的内存“免费”?

其他进程的do_mmap_pgoff

Linux内核如何决定使用哪个内存区域?

原生应用程序的初始内存占用空间较大

首先通过以下命令检查是否可以分配多达50G的堆:

java -xms50G -version

如果不成功 – 请尝试减少最小堆大小,除非您看到Java版本信息没有错误

只要你没有得到java.lang.OutOfMemoryError: Java heap space错误我相信你的堆大小调优成功应用。

也许你有一个内存密集型监听器被启用,如查看结果树或查看结果表 ? 如果是这样 – 禁用他们(以及任何其他听众)

如果可能的话,至少在Java 6中尝试切换到Oracle JDK,但性能差异巨大。

另外请确保您遵循JMeter Performance and Tuning Tips指南中的建议。

好吧同时我明白了:

请务必阅读Dmriti T的帖子

把Java的堆栈大小设置得很小 – 通常最小的值就足够了。 在我的情况下,200k(另见第4点)

增加sysctl.conf 中打开文件的最大数量 (见第4点)

增加堆的大小 – 但是因为jmeter会创建大量的线程,所以线程在操作系统级上需要留出足够的空间来存放内存空间(所以新的线程需要OS和java堆上的内存 – 因此也要留出足够的内存空间)。下面)

更新limits.conf (见下文)

更新sysctl.conf文件(见下文)

limits.conf中

在/etc/security/limits.conf

* hard nofile 900000 * soft nofile 900000 root hard nofile 900000 root soft nofile 900000

sysctl.conf的

/etc/sysctl.conf中

kernel.pid_max=999999 kernel.thread-max=999999 vm.max_map_count=999999 fs.file-max=999999

注意:是pid _max和thread-max

jmeter.sh / jmeter.bat

你可以在你的jmeter安装的/bin/文件夹中找到它们。

在linux下添加这一行

JVM_ARGS="-Xmx15g -Xss250k"

在实际的Java调用最后一行之前的某个地方。 这将减少为每个线程分配的堆栈大小。

在windows下你必须编辑jmeter.bat。 我没有在窗口下配置它,但至少在堆中应该有一个以set HEAP开始的行。 我不知道在Windows下把-Xss参数放在哪里。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐