- In the application we have something about 30 types of objects that are created repeatedly.
- Some of them have long life (hours) some have short (miliseconds).
- Objects could be created in one thread and destroyed in another.
Does anybody have any clue what could be good pooling technique in the sense of minimal creation/destruction latency, low lock contention and reasonable memory utilization?
Append 1.
1.1. Object pool/memory allocations for one type usually is not related to another type (see 1.3 for an exception)
1.2. Memory allocation is performed for only one type (class) at time, usually for serveral objects at time.
1.3. If a type aggregates another type using pointer (for some reason) these types allocated together in the one continuos piece of memory.
Append 2.
2.1. Using a collection with access serialization per type is known to be worse than new/delete.
2.2. Application is used on different platforms/compilers and cannot use compiler/platform specific tricks.
Append 3.
It becomes obvious that the fastest (with lowest latency) implementation should organize object pooling as star-like factories network. Where the central factory is global for other thread specific factories. Regular object provision/recycling is more effective to do in a thread specific factory while the central factory could be used for object balancing between threads.
3.1. What is the most effective way to organize communications between the central factory and thread specific factories?