lundi 26 février 2018

Design pattern for memory allocation design for object creation

In this previous question I wondered how to decide size for objects. Now to another somewhat similar question. What if I have a solution to create objects in my own little memory play-area. What kind of object oriented design patterns do there exist to decide object size prior to construction?

The point would be two-fold:

  1. to try and make a single external allocation per construction, saving time and memory/pointer management overhead.
  2. by a single allocation we get locality in memory for each object which is nice for cache hitting purposes.

Is there some clever way to pair constructor argument list to for example static functions returning int? Maybe something factory-like?

Aucun commentaire:

Enregistrer un commentaire