C language memory distribution (BSS segment, data segment, code segment, heap and stack)

Source: Internet
Author: User
BSS segment: (BSS segment) refers to a memory area used to store uninitialized global variables in the program. BSS is an English Block
Short for started by symbol. BSS segments belong to static memory allocation.
Data Segment: a data segment is usually a memory area used to store initialized global variables in the program. The data segment belongs to the static memory allocation.
Code segment: A code segment (code segment/Text Segment) is usually a memory area used to store Program Execution Code. The size of this area is determined before the program runs, and the memory area is usually read-only,
Some architectures also allow code segments to be writable, that is, programs can be modified. In the code segment, it may also contain some read-only constant variables, such as string constants.
Heap: a heap is used to store the memory segments dynamically allocated during a process. Its size is not fixed and can be dynamically expanded or reduced. When a process calls functions such as malloc/free to allocate memory, the newly allocated memory is dynamically added to the heap (the heap is expanded) /The released memory is removed from the heap (the heap is reduced)
STACK: A stack is also called a stack. It stores local variables of a program (but does not include static declared variables. Static means to store variables in the data segment ). In addition, when a function is called, the stack is used to pass parameters and return values. Because of the stack's first-in-first-out feature, the stack is particularly convenient for storing/restoring the call site.
Is a typical C memory distribution chart in apue.

From: http://blog.csdn.net/hxg130435477/article/details/8501610

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.