64bit compiled files are approx. 20% bigger than 32bit executables. I think it's same for 64bit OS vs 32bit OS. Thanks god the ratio is not 50%. Is 20% really necessary? Do 64 bit programs consume more RAM either? Will 128bits be much bigger?
Addition: I know 32bit word vs 64bit word. The char 'A' requires 4 bytes in 32 bit mode and 8 bytes in 64bit in memory. Does an executable contain tons of constants which aligned/padded so it's bigger in 64bit form? IMHO the differences between 64bit exe & 32bit exe are instruction codes -I think they don't inflate the file size too much- and static data & memory addresses. If so, an exe contains much more static data than I imagine. It looks like PNG8 vs PNG24 a bit. Or I'm totally wrong.
Depending on the ISA (Intel, ARM, whatever), various instructions need to be word-aligned (which may cause them to take more space), and numerical constants need to match the processor's word size. Binary code is full of int constants: your loops start at zero, etc. In short, the likely cause of the extra space is int padding and word alignment of constant data.
Depending on how it's compiled, 64-bit code may well use more memory. Data structures also want to be word-aligned for fast access, and the compiler may choose to pad your structs. Also, depending on the compiler, some int constants may change size. (That's why you always see typdefs like uint32: guaranteed size.)
Last but not least, pointers take twice the memory.
One reason for writing a 64-bit program is to be able to use more RAM. This requires using 8 bytes for an address instead of 4 bytes in a 32-bit program. That might increase the program size.
On the other hand, if your program handles data that is intrinsically 64 bits, it can do that in a single instruction where a 32-bit program would use two instructions. This would make the program smaller and faster.
The char 'A' uses a single byte in either case, so that doesn't matter.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With