[Operating System] Memory organization structure when the program is running

Source: Internet
Author: User

Similar to Mac OS, Linux, and windows, different types of data are stored in different areas of the memory (segments, sections/segment ). You can specify various parameters when running the linker to control the program's memory organization. The following is a typical memory structure in windows.

(The figure is incorrect. Modify it later)

1) The operating system retains the location with the lowest memory address. Normally, applications cannot access the data of these addresses. One of the main reasons for the system to retain these spaces is to help check the reference of the NULL pointer. the pointer is usually initialized as null to indicate that the pointer is invalid.

2) stack space: a program is used to store local variables and other temporary data.

3) Heap Space: The program is used to maintain dynamic variables.

4) code segment: The machine instruction code used to save the program.

5) constant zone: stores the read-only data generated by the compiler.

6) read-only data segment: stores user-defined data, which can only be read and cannot be written.

7) Static zone: stores user-defined static variables that have been initialized.

8) Storage segment: Also known as BSS, stores user-defined uninitialized variables.

 

Generally, the compiler combines the code segment, constant area, and read-only data segment because the three segments contain read-only data.


Reference: volumn 1: Understanding the machine)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.