[refinement] cleanup allocated memory