The following line of code:
string *p = new(adr) MyObject();
will create a MyObject at adr. Then the next time you create another object, you will find out that the memory in adr is used by the first object, so your next object should be created in adr + sizeof(MyObject) :
string *q = new(adr + sizeof(MyObject)) MyObject();
The point of preallocated memory is such that you do not allocate it at run time, which is pretty slow. You make one big selection at the beginning of the loop / program, and then you just need to use pieces of that selection. The downside is that you have to manage your own memory, which means you need to figure out where to put your objects, which become complex when your memory pool is fragmented!
Andrew Rasmussen
source share