PDA

View Full Version : Is OS wasting memory?


waht
Oct1-09, 12:20 AM
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?

Mark44
Oct1-09, 02:08 AM
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.