Hey everyone! Haven't posted in quite while.. anyway, this post will be about.. why executables are so small. Exact opposite of what I made previous time isn't it? Yep, lets get to it. So, is the executable size limited only by the size of your hard drive? No, of course not, well atleast commonly. Lets say you have Windows 3.1 machine, which you want to run the biggest executable you can on. How do we calculate such thing? Well in this case, our bottleneck will be the bitcount of the processor. In this case the PC is 16bits, so the maximum size it can load to memory is 64kb. Thats preety small right? Thats why static and dynamic libraries exist. I have covered them in one of my previous posts, so I wont go into detail here, but basically the computer can load those into memory and execute additional code on top of its own. But wait, isn't the memory already full of code from the executable? Yep, it absolutely is. In fact the computer wouldn't have enough memory to even begin loading it, if it wasn't for our old friend, segmentation. And I am not talking about segmentation fault, I mean 16bit real mode memory segmentation. What the heck is it? Basically, when computers needed more than 64kb of memory but 8086 architecture was so far only doing 16bit, people were thinking about making the CPU be able to only access part of the bigger memory, but be able to switch between which parts of memory it has accessible. Thats how 20bit addressing was born, and thats also why you can access up to 1 megabyte of memory in real mode, when making bootloader to your fancy os. So your executable could span 64kb, and your other libraries could span the whole rest, so 15another segments(~983040b). Now lets get to a bit more.. modern technology, lets talk about windows. Windows has maximum executable size of 4GB from the old days of Windows XP and older, where maximum memory size was 4GB because it was 32bit(2^32 = 4294967296 = 4gibibits = 4.29 gigabytes), or to be more precise, the maximum amount of memory + swap area you have in your system - the memory taken up by your system. We can however extend that by loading the program memory manually from inside the program. This is however similiar to shared libraries, so I won't cover that here. With linux.. its complicated. In theory, you could load up to several exabyte file, but we will simply not find out until we don't make hard drive that big.