{"id":1683,"date":"2020-09-10T09:32:54","date_gmt":"2020-09-10T09:32:54","guid":{"rendered":"https:\/\/loadfocus.com\/blog\/?p=1683"},"modified":"2021-12-21T11:57:51","modified_gmt":"2021-12-21T11:57:51","slug":"how-to-increase-heap-size-in-jmeter","status":"publish","type":"post","link":"https:\/\/loadfocus.com\/blog\/2020\/09\/how-to-increase-heap-size-in-jmeter","title":{"rendered":"How to Increase Heap Size in JMeter?"},"content":{"rendered":"<span class=\"span-reading-time rt-reading-time\" style=\"display: block;\"><span class=\"rt-label rt-prefix\"><\/span> <span class=\"rt-time\"> 2<\/span> <span class=\"rt-label rt-postfix\">minutes read<\/span><\/span><!-- pn-tldr --><h2>Key takeaways<\/h2><ul><li>JMeter defaults to a small heap, which causes out-of-memory failures on large tests.<\/li><li>Raise the heap in the startup script, and run non-GUI with listeners disabled.<\/li><li>If you still run out, the answer is distributed load rather than a bigger heap.<\/li><\/ul><!-- \/pn-tldr -->\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p class=\"lead\">Why is Apache JMeter very slow when creating and running load tests?<\/p><\/blockquote>\n\n\n\n<p>If you just downloaded and opened <strong>Apache JMeter<\/strong> and the UI it feels very slow, here are some items you can follow to make Apache Jmeter GUI move faster.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Increase the Apache JMeter Heap Size<\/h2>\n\n\n\n<ol class=\"wp-block-list\"><li><strong>Apache JMeter<\/strong> is a Java application, this means you have to increase the Java Virtual Machine initial heap size and maximum heap size<\/li><li>The easiest way to increase the heap sizes is to edit the <code>jmeter.bat<\/code> file and add the following line:<\/li><\/ol>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1280\" height=\"678\" src=\"https:\/\/loadfocus.com\/blog\/wp-content\/uploads\/Screenshot-2021-12-21-at-13.54.34-1280x678.png\" alt=\"\" class=\"wp-image-2321\" srcset=\"https:\/\/loadfocus.com\/blog\/wp-content\/uploads\/Screenshot-2021-12-21-at-13.54.34-1280x678.png 1280w, https:\/\/loadfocus.com\/blog\/wp-content\/uploads\/Screenshot-2021-12-21-at-13.54.34-800x424.png 800w, https:\/\/loadfocus.com\/blog\/wp-content\/uploads\/Screenshot-2021-12-21-at-13.54.34-600x318.png 600w, https:\/\/loadfocus.com\/blog\/wp-content\/uploads\/Screenshot-2021-12-21-at-13.54.34-768x407.png 768w, https:\/\/loadfocus.com\/blog\/wp-content\/uploads\/Screenshot-2021-12-21-at-13.54.34.png 1428w\" sizes=\"auto, (max-width: 1280px) 100vw, 1280px\" \/><figcaption>JMeter.bat file to edit in order to change the heap size<\/figcaption><\/figure>\n\n\n<p>[emaillocker id=&#8221;1703&#8243;]<\/p>\n<p><strong>Find the following line:<\/strong><\/p>\n<pre># This is the base heap size -- you may increase or decrease it to fit your<br \/># system's memory availability:<br \/>: \"${HEAP:=\"-Xms1g -Xmx1g -XX:MaxMetaspaceSize=256m\"}\"<\/pre>\n<p><strong>or if that is missing, add the line below:<\/strong><\/p>\n\n\n<pre class=\"wp-block-preformatted\">set HEAP=-Xms2g -Xmx2g -XX:MaxMetaspaceSize=12g<\/pre>\n\n\n\n<p>Save the changes made in the <code>jmeter.bat<\/code> file and restart JMeter. Now creating JMeter test scripts will feel much faster.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Run your JMeter load test in non-GUI mode<\/h2>\n\n\n\n<p>More details on how to run your JMeter test in non-GUI mode can be found <a href=\"https:\/\/jmeter.apache.org\/usermanual\/get-started.html#non_gui\">here<\/a>, however here is a quick example:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">jmeter -n -t my_test.jmx -l log.jtl -H my.proxy.server -P 8000<\/pre>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Disable JMeter listeners during test execution<\/h2>\n\n\n\n<p>Most likely you don&#8217;t need the listeners during test execution, so you can easily disabled them by pressing <code>Ctrl\/Cmd + T<\/code>  and have the disabled during the test run.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Monitor machine resources CPU, Memory, Network <\/h2>\n\n\n\n<p>You can easily monitor the resources of the machine where JMeter load tests are running upon by using a plugin:<a href=\"https:\/\/jmeter-plugins.org\/wiki\/PerfMon\/\" rel=\"nofollow\"> JMeter PerfMon plugin<\/a>. Check more details on <a href=\"https:\/\/loadfocus.com\/blog\/2020\/09\/how-to-install-extra-plugins-in-jmeter-using-the-plugins-manager\/\" title=\"How to install extra plugins in JMeter using the Plugins Manager?\">how to install JMeter plugins<\/a> in our other post.<\/p>\n\n\n\n<p>By now, your JMeter test creation should feel much faster and your non-GUI performance tests should behave better.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Update Java to the Latest Version<\/h2>\n\n\n\n<p>Check which version of Java you have installed on your machine, for Mac users you can check by typing in the terminal the following command:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>\/usr\/libexec\/java_home -V<\/code><\/pre>\n\n\n\n<p>Written by <a href=\"https:\/\/coursinator.com\/instructor\/bogdan-vazzolla\" class=\"broken_link\">Bogdan Vazzolla<\/a>.<\/p>\n\n\n<p>[\/emaillocker]<\/p>\n\n\n<p>With <a href=\"https:\/\/loadfocus.com\/jmeter-load-testing\">JMeter Cloud Load Testing Tool<\/a> from <a href=\"https:\/\/loadfocus.com\/\">LoadFocus<\/a>, you can upload your Apache JMeter test scripts (.jmx files), run and analyse JMeter results from multiple world locations, everything in an easy to use UI.<\/p>\n<!-- pn-faq --><h2>Frequently Asked Questions<\/h2><h3>Why does JMeter run out of memory?<\/h3><p>Because it defaults to a modest heap, which is fine for building a plan and too small for a large run. The failure usually arrives well into a test, which makes it expensive.<\/p><h3>How do I raise it?<\/h3><p>Set the heap in the JMeter startup script, and run non-GUI with listeners disabled so the memory goes to generating load rather than to storing and drawing results.<\/p><h3>What if it still runs out?<\/h3><p>Distribute the load across machines. Past a point a bigger heap is delaying a limit rather than removing it, and one machine cannot generate the traffic anyway.<\/p><!-- \/pn-faq --><!-- pn-related-reading --><h2>Related reading<\/h2><ul><li><a href=\"https:\/\/loadfocus.com\/blog\/2016\/05\/how-to-start-apache-jmeter-in-non-graphical-non-gui-mode\">How to start Apache JMeter in non-graphical (non-GUI) mode?<\/a><\/li><li><a href=\"https:\/\/loadfocus.com\/blog\/2020\/09\/how-to-install-jmeter-on-mac\">How to Install JMeter on Mac?<\/a><\/li><li><a href=\"https:\/\/loadfocus.com\/blog\/2016\/04\/how-to-use-apache-jmeter-to-load-test-a-web-server\">How To Use Apache JMeter To Load Test a Web Server<\/a><\/li><\/ul>","protected":false},"excerpt":{"rendered":"<p><span class=\"span-reading-time rt-reading-time\" style=\"display: block;\"><span class=\"rt-label rt-prefix\"><\/span> <span class=\"rt-time\"> 2<\/span> <span class=\"rt-label rt-postfix\">minutes read<\/span><\/span>Key takeaways JMeter defaults to a small heap, which causes out-of-memory failures on large tests. Raise the heap in the startup script, and run non-GUI with listeners disabled. If you still run out, the answer is distributed load rather than a bigger heap. Why is Apache JMeter very slow when creating and running load tests?&#8230;  <a href=\"https:\/\/loadfocus.com\/blog\/2020\/09\/how-to-increase-heap-size-in-jmeter\" class=\"more-link\" title=\"Read How to Increase Heap Size in JMeter?\">Read more &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":1614,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8,9],"tags":[290,289],"class_list":["post-1683","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-apache-jmeter","category-load-testing","tag-jmeter-gui-is-very-slow","tag-jmeter-heap-size"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/loadfocus.com\/blog\/wp-json\/wp\/v2\/posts\/1683","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/loadfocus.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/loadfocus.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/loadfocus.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/loadfocus.com\/blog\/wp-json\/wp\/v2\/comments?post=1683"}],"version-history":[{"count":0,"href":"https:\/\/loadfocus.com\/blog\/wp-json\/wp\/v2\/posts\/1683\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/loadfocus.com\/blog\/wp-json\/wp\/v2\/media\/1614"}],"wp:attachment":[{"href":"https:\/\/loadfocus.com\/blog\/wp-json\/wp\/v2\/media?parent=1683"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/loadfocus.com\/blog\/wp-json\/wp\/v2\/categories?post=1683"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/loadfocus.com\/blog\/wp-json\/wp\/v2\/tags?post=1683"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}