freed memory at end