Release memory when it crash.

Signed-off-by: yushijinhun <yushijinhun@gmail.com>