The application de-serializes a stream into dynamically allocated objects and then keeps base type pointers in a linked list (i.e. abstract factory). It’s too slow. Profiling says all the time is spent in operator new.
Notes: The application already uses a custom memory allocator that does pooling. The compiler is VC++ 6.0 and the code uses the old RogueWave collections rather than the STL.
The only idea I have right now is to introduce Object Pooling. I’d maintain large collections of pre-allocated objects for each type and re-use them. But this will be a lot of work in this old code, and I’m not yet sure there’s enough re-use that it would even help. I was hoping someone smarter than me has an idea.
The only way is to reduce the number of memory allocations. Have you used a profiler that will tell you exactly what is doing the allocation? Are you possibly doing some string manipulation?
If all the time is spent allocating the objects the factory is creating, you may need to go to a pool.