Add release_mem() function