Fix memory link.

1) Fix typo: should be deallocate.
2) Fix memory link after instance destoryed.
3) Add function clear.