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.

My first computer

Nostalgia time. While reading a few Wikipedia articles, just remembered that my first computer was a Timex 2068, which in fact was a clone of the ZX Spectrum 48k. I got it in 1987 but I was used to play with other computers (friends, school, etc) like the Commodore 64, Atari ST, Phillips MSX, etc. The Timex 2068 had a cartridge system but with limited support. I had a few ones (a word processor and a Spectrum 48k emulator cartridge to load games using the cassette player). My first language was of course, BASIC. Those were the days. I remember the exact day when I have used a computer. I was a kid in 1984 and at the time I was living in Brazil. I went to an exhibition where there was a TK 82C (a brazilian clone of the ZX81) connected to a big and ugly green monitor playing the Game of Life (very popular at that time as a demo BASIC program). I immediatly fell in love with computers.