C Language Memory allocation

Source: Internet
Author: User

There are 5 main areas of memory allocation for C languages:

1. Stack area : When executing a function, a local variable within the function (not including the static variable), the function return value of the storage unit is created on the stack area. These storage units are automatically freed at the end of the function execution. The stack memory allocation operation is built into the processor's instruction set, which is highly efficient, but allocates limited memory capacity.

2, heap area : The program in the run time with malloc (calloc, realloc, etc.) application of memory, to be the programmer's own responsibility to free up memory.

3. Static storage : Store global variables and static variables. The program is compiled at the time it is distributed, and exists during the entire run of the program.

4, constant area : integer constants, floating-point constants, character-type constants and string constants are allocated in the literal constant area, the program is released after the end of the system.

5. Code Area : The memory area where the entire program code is stored. The data and code are stored separately.

C Language Memory allocation

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.