Something wrong with the mem_freed
this is my undone version, the mem_freed cannot work well now.