Subj : Re: OO compilers and efficiency To : comp.programming From : Paul Dietz Date : Mon Jul 25 2005 11:12 am Jon Harrop wrote: > No, either or both of malloc and free are expensive. Which is cheap is not > usually known to the programmer (usually malloc is cheaper). It is this not > knowing that leads to inefficient code with manual allocation and > deallocation via malloc and free. If you want to optimise your code then > you should malloc a big block of memory and write your own customised > memory allocation and deallocation routines. > > This is why malloc/new and free/delete are replaced by much faster, custom > "allocators" in the C++ STL. Or both can be expensive. I've seen some rather badly implemented allocators out there. One common screw up is to not realize that synchronization cost can dominate in these calls if the program has more than one thread. Paul .