Does optimizing for size with gcc -Os only reduce the binary size of a program, or does it reduce its runtime memory usage as well? I know what exactly the results are depend on the specific code, but in general is the result a lower memory usage?
|
|
|
Obviously, since the program needs to be loaded into memory, |
|||||||||||||||||
|
|
Actually, according to some sources like gentoo-wiki, the Also keep in mind that |
||||
|
|
|
As Kim says, the resulting binary is smaller, so the stack memory usage will be smaller too. It might also be faster than some other optimisation flags, because more of the program will fit into the CPU caches. That's one reason it has become more popular of late. |
|||
|
|
|
One aspect is that -Os will try to give you a smaller application, and since it is smaller sometimes it will execute faster since there is less code to execute. |
|||||||
|