Quote:
Originally Posted by
_uj
My conclusion is that for serious OO programming to be feasible in C++ the standard memory allocator must be replaced with something more efficient. The standard allocator sucks and is likely to be a major bottleneck. That's the plain and simple truth, and it amazes me that this fact isn't out more in the open. Especially since C++ is considered to be THE language for efficiency conscious programmers. I suggest anybody with an ambition to write fast and nimble OO programs immediately start looking for a better memory allocator.
In order to support that conculsion, you would have to analyze a sample set of applications with different allocators, and measure the application level performance difference.
But there is an even eaiser way to contratict your conclusion...There are hundreds of thousands of C"Serious OO programs" written in C++ using the default allocator. If you conclusion were true, then these programs would not exist.
I HAVE done a significant amount of performance analysis on applications ranging from massive business applications to high performance real-time systems (including industrial process/machine control and military weapons systems [no good shooting where the plane was]. Only in very very rare cases was heap management even measurable as an impact on performance.
The following numbers are from a project I just completed on real-time gas dispersion:
Sample Time: 132.3 mS
Heap Allocations: 32,418
Heap ManagemenrtTime: 2.83mS
So we have (using the allocator provided with VC++ 9.0, a 2.13% time spent dealing with the heap.
Assume you have an allocator which is 100 times faster. You would get.
Sample Time: 129.5 mS
Heap Allocations: 32,,418
Heap Management Time: 0.0283mS
This represents a 2.11% performance improvement. Hardly a significant issue.
You are falling into the trap of premature optimization. The cases where an optimized allocator makes sense is when the number of (small) allocation/release cycles are extremely high AND there is little or no code in the constructor/destructor [ie you are making heavy use of the FlyWieght pattern]