fix memory allocation, now 0 bytes reamin after leaving