cleanup ptr free

- add delete allocated ptr
- use __delete() to free allocated memory