我正在尝试为应用程序运行负载测试。为此,我在Ubuntu上使用JMeter (v.2.13),内存为60 Vm,CPU处理能力充足。目标是通过WebSocket连接到10k个用户。
但是,在测试运行期间,我在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 information 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, 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.
# 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文件中发出java命令之前添加以下行来修改jmeter.sh,从而分配更多的内存:
JVM_ARGS="-Xms5g -Xmx20g -Xss300k"我还尝试使用以下命令设置_JAVA_OPTIONS环境变量
export _JAVA_OPTIONS="-Xms5g -Xmx20g"最后我找到了这个命令
sysctl -w vm.max_map_count=500000top-Command为我提供了以下有关内存的信息
KiB Mem: 61836576 total, 15163400 used, 46673176 free, 10636 buffers
KiB Swap: 0 total, 0 used, 0 free. 94492 cached Mem更新
仅供参考:除了简单的数据写入器之外,我在JMeter中不使用任何侦听器。但是,即使我禁用了最后一个侦听器,也会抛出错误。
java -Xms40g -version是成功的-所以我真的可以分配这么多内存
我使用以下命令减少了堆栈的大小
-Xss300k这至少帮了我一些忙,因为我现在得到了一个
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的值
是我错过了什么,还是我做错了什么?谢谢你的帮助。
发布于 2015-03-25 22:03:57
好吧,同时我想通了:
sysctl.conf- limits.conf (参见下文)
limits.conf
/etc/security/limits.conf
* hard nofile 900000
* soft nofile 900000
root hard nofile 900000
root soft nofile 900000sysctl.conf
/etc/sysctl.conf
kernel.pid_max=999999
kernel.thread-max=999999
vm.max_map_count=999999
fs.file-max=999999注意:pid是_最大值和线程最大值
jmeter.sh / jmeter.bat
您可以在jmeter安装的/bin/文件夹中找到这些文件。
在linux下,添加以下行
JVM_ARGS="-Xmx15g -Xss250k"在最后一行的实际java调用之前的某个地方。这将减小分配给每个线程的堆栈大小。
在windows下,您必须编辑jmeter.bat。我没有在windows下配置它,但至少关于堆,应该有一行以set HEAP开头。我不知道在windows下把-Xss参数放在哪里。
发布于 2015-03-25 20:01:40
首先,检查是否可以通过以下命令分配多达50G的堆:
java -Xms50G -version如果不成功,请尝试减少最小堆大小,除非您看到Java版本信息没有错误。
只要你的NOT java.lang.OutOfMemoryError: Java heap space error,我相信你的堆大小调整是成功的。
也许您启用了内存密集型监听程序,如View Results Tree或View Results in Table?如果是这样-禁用它们(以及任何其他监听程序)
如果可能,请尝试切换到Oracle JDK,因为至少对于Java 6而言,性能差异是巨大的。
还要确保你遵循了JMeter Performance and Tuning Tips指南中的建议。
https://stackoverflow.com/questions/29250953
复制相似问题