Fixing memory leaks in memstats