|
From: Eliot M. <mo...@cs...> - 2014-05-14 21:46:46
|
On 5/14/2014 2:21 PM, Rob Taylor wrote: > Thank you Milian Wolff and Eliot Moss, Typical users of tools like valgrind have more background in how all this works -- not a criticism of you, just a difference in expectation. The volume of code that results from compiling a program consisting of a main function that simply returns is quite small. It is stored on disk in the executable file produced by the C compiling and linking process. That file also describes any global / static storage needed for the program. When a process is created to run the program, the operating system sets up an area in low memory (not the stack) for that data. Local / automatic (in C terminology) variables are allocated in the stack, and done so by each function as you enter the function. The operating system grows the stack (from high addresses toward lower ones) automatically. It is also possible to allocate, and "free", memory on request using library functions such as malloc and free. Any libraries used will be linked in (connected to your code) on demand, and they may also have static data areas and may malloc/free data as well. You may benefit from finding documentation or a textbook about how compiling, linking, loading, etc., works for C programs in Unix/Linux, etc. (The Windows world is similar, though of course different in some details.) Regards -- Eliot Moss |