title: Why is C++ initial allocation so much larger than C's?
body: <p>When using the same code, simply changing the compiler (from a C compiler to a C++ compiler) will change how much memory is allocated. I'm not quite sure why this is and would like to understand it more. So far the best response I've gotten is "probably the I/O streams", which isn't very descriptive and makes me wonder about the "you don't pay for what you don't use" aspect of C++.</p>
  
  <p>I'm using the Clang and GCC compilers, versions 7.0.1-8 and 8.3.0-6 respectively. My system is running on Debian 10 (Buster), latest. The benchmarks are done via Valgrind Massif.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int main() {
      printf("Hello, world!\n");
      return 0;
  }
  </code></pre>
  
  <p>The code used does not change, but whether I compile as C or as C++, it changes the results of the Valgrind benchmark. The values remain consistent across compilers, however. The runtime allocations (peak) for the program go as follows:</p>
  
  <ul>
  <li>GCC (C): 1,032 bytes (1 KB)</li>
  <li>G++ (C++): 73,744 bytes, (~74 KB)</li>
  <li>Clang (C): 1,032 bytes (1 KB)</li>
  <li>Clang++ (C++): 73,744 bytes (~74 KB)</li>
  </ul>
  
  <p>For compiling, I use the following commands:</p>
  
  <pre><code>clang -O3 -o c-clang ./main.c
  gcc -O3 -o c-gcc ./main.c
  </code></pre>
  
  <pre><code>clang++ -O3 -o cpp-clang ./main.cpp
  g++ -O3 -o cpp-gcc ./main.cpp
  </code></pre>
  
  <p>For Valgrind, I run <code>valgrind --tool=massif --massif-out-file=m_compiler_lang ./compiler-lang</code> on each compiler and language, then <code>ms_print</code> for displaying the peaks.</p>
  
  <p>Am I doing something wrong here?</p>