The object indicated by x is on the stack. vector::push_back will copy it to the heap.
The allocator object inside vector is likely to be implemented using new or malloc , although it is possible that it uses a different low-level API. For example, both Unix and Windows offer memory matching APIs, which in turn can be used to implement malloc , new and allocators.
source share