added memory-free function