When you compile a C program, it is associated with an executable file. Although your program is very small, it will reference the C runtime, which will contain some additional code. Some error handling may occur, and this error handling may be written to the console, and this code may include sprintf , which adds some trace to your application. You can request the linker to create a code map in your executable file to see what is actually included.
In addition, the executable file contains more machine code. There will be various tables for data and dynamic linking that increase the size of the executable, and there may also be some wasted space because the various parts are stored in blocks.
The C runtime will be initialized before the main call, and this will lead to loading of some loadable code (for example, by dynamically linking to various functions of the operating system), as well as memory allocated for the heap, stack for each thread, and possibly also some static data. Not all of this data can be displayed as βreal memoryβ - the default stack size for OS X is 8 MB, and your application still uses much less than that.
Martin liversage
source share