简体   繁体   English

Jmeter,如何增加堆大小

[英]Jmeter, how to increase heap size

I had read that you need to change the heap size in the jmeter.bat file (I'm using windows) to increase the memory to be able to test around 500 threads or more. 我读过您需要更改jmeter.bat文件(我使用Windows)中的堆大小以增加内存,以便能够测试约500个或更多线程。 This is the default: 这是默认值:

if not defined HEAP (
    rem See the unix startup file for the rationale of the following parameters,
    rem including some tuning recommendations
    set HEAP=-Xms1g -Xmx1g -XX:MaxMetaspaceSize=256m
)

I changed the set HEAP=-Xms1g -Xmx1g -XX:MaxMetaspaceSize=256m it to: set HEAP=-Xms1g -Xmx1g -XX:MaxMetaspaceSize=256m为:

set HEAP=-Xms2g -Xmx8g -XX:MaxMetaspaceSize=512m

But when I open Jmeter in GUI mode there is a message in the command line window 但是当我在GUI模式下打开Jmeter时,命令行窗口中会显示一条消息

Modify current env variable HEAP="-Xms1g -Xmx1g -XX:MaxMetaSpaceSize=256m" in the jmeter batch file

So does that mean the change in the batch file didn't work? 那么这是否意味着批处理文件中的更改不起作用? Or it does work when running in non-gui mode? 还是在非GUI模式下运行确实有效? Did I miss something to change or what? 我错过了要更改的东西吗? Thanks in advance. 提前致谢。

  1. You don't need to increase the heap unless you face java.lang.OutOfMemoryError: Java heap space error or detect unusually high GC activity 除非遇到java.lang.OutOfMemoryError: Java heap space错误或检测到异常高的GC活动,否则无需增加堆
  2. The message basically a form of advice, you will see it even if you have several terabytes of heap space as it is simply hard-coded and will always be shown during GUI startup. 该消息基本上是一种建议形式,即使您拥有几TB的堆空间,您也将看到它,因为它只是简单地硬编码,并且总是在GUI启动期间显示。 If you want to see all Java arguments including heap space settings you can use JSR223 Sampler and the following Groovy code: 如果要查看所有Java参数(包括堆空间设置),可以使用JSR223 Sampler和以下Groovy代码:

     java.lang.management.ManagementFactory.getRuntimeMXBean().getInputArguments().each { log.info("Effective JVM argument: " + "$it") } 

    This way you can test whether you changes are applied or not: 通过这种方式,您可以测试是否应用了更改:

    在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM