Hack to get around perl-API memory leak for now.
Added testcases specifically for memleak checking, which I have to
try from another machine because valgrind doesn't like OSX.