JMeter:jmeter.bat 和 java 中的堆大小可以相同吗?

JMeter: Can heapsize in jmeter.bat and java be same?

我想知道我可以在 jmeter.bat 和 Java 中为我的 64 位 Windows 8 OS、16GB RAM 增加多少堆大小以避免 GC 开销超出限制。

此外,jmeter.bat 和 java 中的 heapsize 可以相同吗?

根据 Java SE 6 HotSpot[tm] Virtual Machine Garbage Collection Tuning 文章Excessive GC Time and OutOfMemoryError 章节

The concurrent collector will throw an OutOfMemoryError if too much time is being spent in garbage collection: if more than 98% of the total time is spent in garbage collection and less than 2% of the heap is recovered, an OutOfMemoryError will be thrown. This feature is designed to prevent applications from running for an extended period of time while making little or no progress because the heap is too small. If necessary, this feature can be disabled by adding the option -XX:-UseGCOverheadLimit to the command line.

The policy is the same as that in the parallel collector, except that time spent performing concurrent collections is not counted toward the 98% time limit. In other words, only collections performed while the application is stopped count toward excessive GC time. Such collections are typically due to a concurrent mode failure or an explicit collection request (e.g., a call to System.gc()).

这通常表明您的 Java 应用程序存在一些问题,在您的情况下 - 使用 JMeter 测试。

  1. 首先,确保您遵循 9 Easy Solutions for a JMeter Load Test “Out of Memory” Failure 指南中的建议以充分利用您的 JMeter 实例

  2. 尝试切换到 Concurrent Mark Sweep Garbage Collector。为了使用它,将下一行添加到 JMeter 启动脚本中的 ARGS:

    -XX:+UseConcMarkSweepGC
    
  3. 如果它没有帮助并且您完全确定您的 JMeter 脚本和 JVM 参数没问题,您可以通过上述 -XX:-UseGCOverheadLimit 设置