On Monday, 5 August 2013 at 12:41:19 UTC, Tobias Pankrath wrote:
On Monday, 5 August 2013 at 08:11:59 UTC, JS wrote:

I guess you mean that I should use a template as a factory instead of an interface? I'll have to think about it to see what the pro's and con's of each are. The interface pattern should include the template pattern though. (after all, the interface is parameterized...)

If you want to swap your allocators at runtime than an interface is a good solution. They are here for runtime dispatch after all. However all your allocators are forced to be classes.

Coincidentally an article has been written about exactly this maybe a week ago. See http://blog.thecybershadow.net/2013/07/28/low-overhead-components/ .

What I would like is some way to choose an approximate optimal allocator that can be modified at run-time if necessary.

e.g., small objects can use a slab allocator. Large objects can use a buddy allocator. I can change the allocator type at application startup to something else entirely if necessary for various reasons(performance checking, memory leakage, etc...).

What I would like is for classes to be able to request a certain allocator(this way, the class writer can attempt to choose the best. Later on, I can profile different allocators rather easily by just changing the factory and force the classes to use the best one found.

There seems to be a lot on the specifics that I'll have to read up on but I mainly want to avoid programming myself into a corner.

Reply via email to