I am working on a plugin for an application, where the memory should be allocated by the Application and keep track of it. Hence, memory handles should be obtained from the host
vector
uses std::allocator
by default, and std::allocator
is required to use global operator new (that is, ::operator new(size_t)
) to obtain the memory (20.4.1.1). However, it isn't required to call it exactly once per call to allocator::allocate
.
So yes, if you replace global operator new then vector
will use it, although not necessarily in a way that really allows your implementation to manage memory "efficiently". Any special tricks you want to use could, in principle, be made completely irrelevant by std::allocator
grabbing memory in 10MB chunks and sub-allocating.
If you have a particular implementation in mind, you can look at how its vector
behaves, which is probably good enough if your planned allocation strategy is inherently platform-specific.