S
sulekha
Hi all,
I was reading the book "Write Great Code vol 1" by Ryndall hyde
in this book chapter 11 is named as Memory architecture &
Organization. in this chapter there is a section named "Run time
memory organization"
author goes on to say that the run time memory is divided into
different sections namely
1) The code section (which holds programs machine instructions)
2) The constant section
(which holds compiler generated read only data)
3) The read only data section,that holds user-defined data that only
be read, never written
4) the static section ,which holds user defined ,initialized static
variables
5) The BSS section ,that holds user-defined un - initialized variables
6) The stack section, where program keeps local variables & other
temporary data
7) The heap section , where program maintains dynamic variables
8) the section reserved for O.S
Most of the time , a given application can live with the default
layouts chosen for these sections by the compiler and linker/loader
In some cases, however , knowing the memory layout can allow you to
develop shorter programs.
for ex , as the code section is usually read only , it may be possible
to combine the code,constants, and read-only data sections into a
single section , thus saving any padding space that the compiler/
linker may place between those sections.
Now my question is as follows can anybody give examples for the above
statement??
I was reading the book "Write Great Code vol 1" by Ryndall hyde
in this book chapter 11 is named as Memory architecture &
Organization. in this chapter there is a section named "Run time
memory organization"
author goes on to say that the run time memory is divided into
different sections namely
1) The code section (which holds programs machine instructions)
2) The constant section
(which holds compiler generated read only data)
3) The read only data section,that holds user-defined data that only
be read, never written
4) the static section ,which holds user defined ,initialized static
variables
5) The BSS section ,that holds user-defined un - initialized variables
6) The stack section, where program keeps local variables & other
temporary data
7) The heap section , where program maintains dynamic variables
8) the section reserved for O.S
Most of the time , a given application can live with the default
layouts chosen for these sections by the compiler and linker/loader
In some cases, however , knowing the memory layout can allow you to
develop shorter programs.
for ex , as the code section is usually read only , it may be possible
to combine the code,constants, and read-only data sections into a
single section , thus saving any padding space that the compiler/
linker may place between those sections.
Now my question is as follows can anybody give examples for the above
statement??