IGTHORN wrote:
My gut tells me that delete [] would free each individual element of the array. But compiler optimizations would probably be smart enough to just free the whole block if there's no destructor method.
The C++ manual states that objects created with new[] should also get deleted together with delete[]. You gut feeling would be one valid implementation internally, but it is incorrect to make such assumptions.
I don't know what the new[] and delete[] operators do in this case, it may be useful to have a look at its API.
To be honest, I don't understand the reason of the question of the OP. Using free versus delete is a consequence of using malloc versus new during construction. Compared to the effort of doing memory administration in the first place, I don't think the difference is measurable in the case of not having destructors. If it is measurable, you must be doing a lot of memory operations, and you may want to consider using a cheaper solution, eg use a pool of free objects or so.
_________________
My project: Messing about in
FreeRCT,
dev blog, and IRC #freerct at oftc.net