title: C++ Size of Struct with Vectors as Members
body: <p>I have a struct which has some vectors as members:</p>
  
  <pre><code>struct my_struct
  {
      std::vector&lt;int&gt; x;
  //  more members here
  };
  </code></pre>
  
  <p>and an instance of my_struct:</p>
  
  <pre><code>my_struct A;
  </code></pre>
  
  <p>The vector(s) inside the struct can obviously change during the program's execution, with statements such as</p>
  
  <pre><code>A.x.resize(...);
  </code></pre>
  
  <p>or
      A.x.push_back(...);</p>
  
  <p>My question is, is there any way to know the size in memory of A at some point during the program? sizeof(A) does not return the correct answer, because of the vector members.</p>