fix memory leak (use std::default_delete for memory array)
fix memory leak bugs