issue  #5791 : use new/delete [] instead of malloc/free for object array

To create an array of object, malloc/free will not call the constructor/destructor of the class, and the members of the class maybe not initialized, and we need to call constructor manually.
The correct way is to use `new operator`.