Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Is OS wasting memory?

  1. Sep 30, 2009 #1
    I did a quick experiment. First I compiled a simple hello world program in C++ , using a gcc compiler. The source code is 100 bytes, but the executable file it 9.6 kb.

    Then I dumbed the executable into hex using xxd, to check up on the 0s and 1s. It turns out there is a huge gap, almost a kilobyte long of zeros.

    I'm wondering if this is some sort of delay, or just unused bits?
  2. jcsd
  3. Oct 1, 2009 #2


    Staff: Mentor

    I'm guessing that the section with 0s is the data segment of your program, and that unless you specify otherwise, it will allocate a 1K block for it. I don't have any experience with gcc, so don't know if you can configure it to use less memory. Check the docs for gcc.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook