Placement new is what you are looking for. Example:
void *blob = numa_alloc_onnode(sizeof(Object), ...);
Object *object = new(blob) Object;
Question
Simple C code can use libnuma
library to allocate memory in specific memory node in a NUMA system. For example, it can be done using following function:
void *numa_alloc_onnode(size_t size, int node)
How one instantiate a class in some memory node? One way, I can think of is:
numa_set_membind(<nodemask>);
o = new Object();
numa_set_localalloc();
Will this work?
Solution
Placement new is what you are looking for. Example:
void *blob = numa_alloc_onnode(sizeof(Object), ...);
Object *object = new(blob) Object;