Yes, the vector itself is an automatic (stack) object. But the vector contains a pointer to its contents (internal dynamic array) and will be allocated to the heap (by default). To simplify things a bit, you can think of vector as making calls to malloc / realloc or new[] internally (it actually uses a allocator ).
EDIT: As I noticed, automatic variables are allocated on the stack, and malloc usually allocated on the heap. The available memory for each of them is a platform and even specific to the configuration, but the available stack memory is usually much limited.
source share