What is the memory overhead of having an empty vector vs having a pointer to a vector?
Option A:
std::vector v;
Option B
In Visual Studio Community 2017 (Version 15.2), running this code:
#include
#include
using namespace std;
void main()
{
vector test;
vector* test2 = &test;
cout << sizeof(test) << "\n";
cout << sizeof(test2) << "\n";
cout << "\n";
system("pause");
}
Running in 32 bit (x86), I get 16 bytes for the vector and 4 bytes for the vector pointer.
Running in 64 bit (x64), I get 32 bytes for the vector and 8 bytes for the vector pointer.