Is OS Wasting Memory? Quick Experiment Results

  • Thread starter Thread starter waht
  • Start date Start date
  • Tags Tags
    Memory Os
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
1 reply · 2K views
waht
Messages
1,502
Reaction score
4
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?
 
Physics news on Phys.org
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.