Jmeter Tips & Tricks – Tip 7

Tip 7 – adjusting the JVM HEAP size, why and how to

When running JMeter tests, it may happen that the test is not successful and JMeter crashes with an OutOfMemoryError. This can happen due to all kinds of things, most of the time however you are trying to generate too many threads with an insufficient amount of memory allocated to your Java Virtual Machine. More information on what the HEAP is, how the JVM deals with the HEAP can be found here.

The HEAP size is defined on startup of your java application, in our case when we start JMeter. In other words, adjusting the HEAP means we will need to adjust the startup script. The startup script can be found in your JMeter “bin” directory. In my case, on a linux environment, it can be found here:


When opening the “jmeter” file in your favorite editor, scroll down until you hit a line stating the following (on Windows based systems open “jmeter.bat”):

# This is the base heap size -- you may increase or decrease it to fit your
# system's memory availability:
HEAP="-Xms512m -Xmx512m"

On Windows systems the line looks slightly different, in the jmeter.bat, due to the nature of BATCH files and DOS working differently from Linux systems

set HEAP=-Xms512m -Xmx512m

When you adjust this line to read something like this:

# This is the base heap size -- you may increase or decrease it to fit your
# system's memory availability:
HEAP="-Xms1024m -Xmx4096m"

the HEAP size will by default be larger, meaning you do not have to think about it anymore when starting JMeter. This does pose one possible challenge, it slows down the startup of JMeter somewhat (at least on most machines I have done it). This seems to be because the JVM will first allocate all the memory you defined in the Xms param, ensuring the JVM is at the appropriate size instantly.

So, we changed the values of Xms and Xmx, what do these two mean?

-Xms ==> minimum heap size. This is the value JAVA will attempt to claim in order to run JMeter. This does NOT imply that it immediately gets this fully allocated by the OS. The OS typically doesn't give an application all blocks it asks for until really needed.
-Xmx ==> maximum heap size. This is the value JAVA will use as a maximum size of the JVM. When JMeter passes this level, an OutOfMemoryError will occur once more.

An alternative, more flexible setup to change the heapsize is to pass the JVM arguments on the commandline when starting JMeter. This of course assumes you are comfortable in commandline and start JMeter from commandline.

[user@machine ]$ JVM_ARGS="-Xms1024m -Xmx2048m" jmeter

Be Aware!

Please always make sure you leave enough memory for your OS and other applications to run on your machine when allocating more HEAP space to a JVM. Not leaving enough memory for your OS to keep running will result in your machine simply being non-responsive and thus your test and testresults being rendered useless.


Linux side-step – create a notification sound for your phone with linux and youtube

Both myself and my wife are big fans of the hit TV show “The Big Bang Theory” (I am assuming here that you will know of this series, if not LMGTFY), especially of the scenes where Sheldon Cooper gets drunk and misbehaves in the most fun and childish ways (for example here during a speech). One of the scenes in particular we both found hilarious, this is when Sheldon has dropped String Theory as his main focus and completely lost focus. He gets drunk and makes prank calls to Stephen Hawking. The bit that always cracks us up is the “Who am I” bit of the prank calls, so I decided to see if I could make this into a notification sound for my wives phone.

All of this was executed on my MSI GS-60 Ghost-Pro running Manjaro Linux.

What did I need?

First of all, find the video on Youtube, that was easy of course.

Download the video

Downloading a Youtube movie is, at least on Linux quite easy. There is a wonderful Python based tool available called “youtube-dl” which can be found on GitHub. All you need for that is Python running on your machine.

Follow the basic instructions as explained on the site, this will make sure you have youtube-dl immediately in your command-line path on your machine:

sudo curl -o /usr/local/bin/youtube-dl
sudo chmod a+rx /usr/local/bin/youtube-dl

Now that it is “installed” it is instanty ready for use. I decided to not look long for a different video or higher quality sound, since I am going to make it into a phone notification anyway. This video is high enough quality for that purpose.

Downloading the video from youtube with youtube-dl is child’s play! Youtube-dl has a immense amount of possible options to pass if you really want, you can find them all in the documentation section of the youtube-dl site.

Let’s do it the easy way:


This will save the file in your current directory in the default formatting based on the video title:

The Big Bang Theory - Drunk Sheldon and Geology feat. Stephen Hawking S07E20 [HD]-aOQp3FHOPyQ.mp4

Pull the sound off the MP4

Now that the video is on your PC somewhere the sound needs to be stripped out of the MP4 video file. To do that ffmpeg is the go-to tool for me! As they themselves state:

FFmpeg is the leading multimedia framework, able to decode, encode, transcode, mux, demux, stream, filter and play pretty much anything that humans and machines have created. It supports the most obscure ancient formats up to the cutting edge. No matter if they were designed by some standards committee, the community or a corporation.

So ensure you have it running on your linux box by punching in something like this:

ffmpeg --version

That should return something like this:

ffmpeg version 2.8 Copyright (c) 2000-2015 the FFmpeg developers
 built with gcc 5.2.0 (GCC)
 configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-avisynth --enable-avresample --enable-fontconfig --enable-gnutls --enable-gpl --enable-ladspa --enable-libass --enable-libbluray --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-shared --enable-version3 --enable-x11grab
 libavutil 54. 31.100 / 54. 31.100
 libavcodec 56. 60.100 / 56. 60.100
 libavformat 56. 40.101 / 56. 40.101
 libavdevice 56. 4.100 / 56. 4.100
 libavfilter 5. 40.101 / 5. 40.101
 libavresample 2. 1. 0 / 2. 1. 0
 libswscale 3. 1.101 / 3. 1.101
 libswresample 1. 2.101 / 1. 2.101
 libpostproc 53. 3.100 / 53. 3.100

Now that you have established it is installed, we can pull the soundtrack off the MP4 file:

ffmpeg -i The\ Big\ Bang\ Theory\ -\ Drunk\ Sheldon\ and\ Geology\ feat.\ Stephen\ Hawking\ S07E20\ \[HD\]-aOQp3FHOPyQ.mp4 The\ Big\ Bang\ Theory\ -\ Drunk\ Sheldon\ and\ Geology\ feat.\ Stephen\ Hawking\ S07E20\ \[HD\]-aOQp3FHOPyQ.wav

This will write the soundtrack away to a WAV file. At this point I got fed up with the long filename, so shortened it to sheldon.wav

I was now left with a wav file of 3:47 mins, which is way too long for a notification or a ringtone and definitely didn’t capture the right part I was looking for properly.

Soundfiles editing

For editing the Wav and saving is as the resulting MP3 I used a very nice simple tutorial from

What it comes down to is install Audacity and use that to find the spot you are looking for. The simple way is to start by looking for the general part of the original WAV file you want to use, zoom in on that time stamp either with the CTRL+1 key combination or with the mouse by selecting the timeslot you want and using the zoom buttons from Audacity.

When you have managed to select the exact piece of the file you can copy that selection and paste it into a new file (e.g. open a new instance of Audacity and paste the sound clip there). Now save that new piece of sound and you have your very own specific, custom ringtone or notification sound just like I made: the slow version and the fast version of a drunk Sheldon Cooper making crazy sounds and mocking Stephen Hawking.

Take these sounds and drop them in the notifications directory of you (android) phone, set them as your default sound for your favorite messaging app.

btw, I noticed later on LinuxJournal covers something very close to this story 🙂