There is a bug in the runtime C library version 1.6.4, which causes memory leaks using malloc/realloc/free standard library functions.The bug is documented as bug 28135 in savannah-non-gnu web site and fixed in version 1.7.0. Unfortunately Arduino doesn't use this version, so I created a workaround function which fixes it:

Good work. But it might be easier to just download the malloc.c file from the 1.7.0 release and add it to any program that needs it (I'm guessing not many programs will use malloc() given how little RAM is available):