Discovering jemalloc and debugging native Java memory leaks

I’ve joined ThoughtWorks last August (awesome!) and I’ve been working with the tech team on everything related to infrastructure automation, code deployment and all things “DevOps” for GOV.UK Verify (part of the Government Digital Services). The last few months were very rewarding to me as I got exposed to a lot of different technologies, although I do tend to work a lot with Puppet most of the time and I don’t get the chance to look at other things “from the other side”. Working with the dev team on a Java memory leak issue was a great way to dig into something where I was already familiar with but I had the chance to understand a little bit more about JVM memory allocation, Linux kernel memory management and discovering great tools like jemalloc and the excellent jeprof profiler. We lost a long time playing the guess game and using the wrong tools before we found this excellent post by Evan Jones from Twitter. This led us to the discovery of jemalloc and I highly recommend having a look at it. It’s really worth it. We (Ozz) also wrote our story on GOV.UK Verify and we hope it can help others when dealing with similar native Java memory leaks.


“Every man who has shown the world the way to beauty, to true culture, has been a rebel, a ‘universal’ without patriotism, without home who has found his people everywhere.”
― Chaim Potok

O regime acabou

Cheira a podre. O regime acabou:

Depois das detenções de Ricardo Salgado e de José Sócrates, que puseram em cheque o sistema financeiro e o sistema político português (a ordem é arbitrária), seja qual for o rumo que os processos venham a tomar – e não se antevê que seja particularmente auspicioso para nenhum dos dois – o regime precisará de forças hercúleas para se salvar, ou ciclópicas, como dizia outra nossa personagem histórica de fim de regime, por sinal também ela transportada de carro no seu momento final. Se o PS e o PSD não perceberem este momento e não se entenderem rapidamente, não ficarão por cá muito tempo para verem o que lhe sucederá.

Rui Albuquerque, Blasfémias.

Poor man’s ssh launcher (CLI)

Problem: just wanted an easy way to add my hosts to the ssh config file and connect to each host through the easiest way possible using normal bash command-line.

Solution: configure your .ssh/config like you normally would, with the following:

Host myapache
User fred

Host myapache2
User fred

Add the following to your .bashrc or .bash_profile (Mac OS X):

shosts=`grep ‘Host ‘ ~/.ssh/config | awk ‘{print $2}’`
for h in $shosts ; do alias $h=”ssh $h” ; done
alias ssh-hosts=’echo -e $shosts | tr ” ” “n”‘

And voilá, if you want to connect to any host, just type the name of the host, for example ‘myapache’. If you want to get a list of ssh hosts, type ‘ssh-hosts’. Keep it simple, stupid.