merge from xiangcheng.liu, memory leak in amf0