C + + Program Memory classification

Source: Internet
Author: User

There are several main memory classifications in the program:

(1) stack storage : The main storage of local variables, function parameters, function return value and so on.

The stack memory is automatically allocated by the compiler when it is needed, and is automatically released when it is exhausted.

(2) heap storage : The space requested by new and malloc.

Need the programmer to apply for themselves, after the use of the timely release , otherwise it will cause memory leaks.

(3) Global data area (static data area): Stores global variables and static variables in the program. The initialized variable is stored separately from the uninitialized variable, but in an adjacent storage area.

The end of the program is released by the system.

(4) literal constant area : stores a constant string. the end of the program is released by the system.

(5) program code area : The binary code that holds the function body.



C + + Program Memory classification

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.