C/C++拾遗之new/delete与malloc/free的异同
SOF上一个比较全面的回答:http://stackoverflow.com/questions/240212/what-is-the-difference-between-new-delete-and-malloc-free
根据理解举例总结如下:
共同点就是都可以用于分配和销毁动态内存。
不同点:
默认是指new/delete :
- 在空内存池(Free Store)上分配内存空间,而malloc是在堆上分配,关于free-store和heap的区别可以看这里, 下面会对内存区域详解。http://stackoverflow.com/questions/1350819/c-free-store-vs-heap