<p>I use the <a href="https://github.com/helm/charts/tree/master/stable/distributed-jmeter" rel="nofollow noreferrer">Distributed JMeter Helm Chart</a>  for distributed benchmarking in Kubernetes.</p>
<p>Depending on the test plan I get the exception:</p>
<pre class="lang-sh prettyprint-override"><code>Uncaught Exception java.lang.OutOfMemoryError: Java heap space in thread Thread[Thread Group 1-45,5,main]. See log file for details.
</code></pre>
<p>And in the jmeter.log file:</p>
<pre class="lang-sh prettyprint-override"><code>2020-06-20 08:57:17,602 ERROR o.a.k.c.u.KafkaThread: Uncaught exception in thread 'kafka-producer-network-thread | producer-24':
java.lang.OutOfMemoryError: Java heap space
    at org.apache.kafka.common.requests.MetadataResponse.lambda$brokersMap$0(MetadataResponse.java:68) ~[kloadgen-1.5.0.jar:?]
    at org.apache.kafka.common.requests.MetadataResponse$$Lambda$222/804455373.apply(Unknown Source) ~[?:?]
    at java.util.stream.Collectors.lambda$toMap$58(Collectors.java:1321) ~[?:1.8.0_252]
    at java.util.stream.Collectors$$Lambda$51/1566067112.accept(Unknown Source) ~[?:?]
    at java.util.stream.ReduceOps$3ReducingSink.accept(ReduceOps.java:169) ~[?:1.8.0_252]
    at java.util.Iterator.forEachRemaining(Iterator.java:116) ~[?:1.8.0_252]
    at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801) ~[?:1.8.0_252]
    at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482) ~[?:1.8.0_252]
    at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472) ~[?:1.8.0_252]
    at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708) ~[?:1.8.0_252]
    at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[?:1.8.0_252]
    at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:566) ~[?:1.8.0_252]
    at org.apache.kafka.common.requests.MetadataResponse.brokersMap(MetadataResponse.java:67) ~[kloadgen-1.5.0.jar:?]
    at org.apache.kafka.common.requests.MetadataResponse.topicMetadata(MetadataResponse.java:202) ~[kloadgen-1.5.0.jar:?]
    at org.apache.kafka.clients.NetworkClient$DefaultMetadataUpdater.handleCompletedMetadataResponse(NetworkClient.java:1037) ~[kloadgen-1.5.0.jar:?]
    at org.apache.kafka.clients.NetworkClient.handleCompletedReceives(NetworkClient.java:845) ~[kloadgen-1.5.0.jar:?]
    at org.apache.kafka.clients.NetworkClient.poll(NetworkClient.java:548) ~[kloadgen-1.5.0.jar:?]
    at org.apache.kafka.clients.producer.internals.Sender.runOnce(Sender.java:331) ~[kloadgen-1.5.0.jar:?]
    at org.apache.kafka.clients.producer.internals.Sender.run(Sender.java:238) ~[kloadgen-1.5.0.jar:?]
    at java.lang.Thread.run(Thread.java:748) [?:1.8.0_252]
</code></pre>
<p>I think I need to increase the heap size over the JVM_ARGS. The <a href="https://jmeter.apache.org/usermanual/get-started.html#running" rel="nofollow noreferrer">JMeter Usermanuel</a>  describes how to set these when starting jmeter. But, how can I set the environment variable via Kubernetes so that <em>all</em> JMeter servers get more memory?</p>
<p>Thanks!</p>

bennex
<p>According to the <a href="https://kubernetes.io/docs/tasks/inject-data-application/define-environment-variable-container/#define-an-environment-variable-for-a-container" rel="nofollow noreferrer">Define an environment variable for a container</a> chapter it should be as simple as changing this section from the <a href="https://github.com/helm/charts/blob/master/stable/distributed-jmeter/templates/jmeter-server-deployment.yaml" rel="nofollow noreferrer">jmeter-server-deployment.yaml</a> as follows:</p>
<pre><code>spec:
  containers:
    - name: {{ .Chart.Name }}
      image: &quot;{{ .Values.image.repository }}:{{ .Values.image.tag }}&quot;
      imagePullPolicy: {{ .Values.image.pullPolicy }}
      args: [&quot;server&quot;]
      ports:
        - containerPort: 50000
        - containerPort: 1099
      env:
      - name: HEAP
        value: &quot;-Xms1G -Xmx2G&quot;
</code></pre>
<p>this will increase the JVM heap size twice.</p>
<p>More information: <a href="https://www.blazemeter.com/blog/9-easy-solutions-jmeter-load-test-%E2%80%9Cout-memory%E2%80%9D-failure" rel="nofollow noreferrer">9 Easy Solutions for a JMeter Load Test “Out of Memory” Failure</a></p>
