iOS Development variables and memory

Source: Internet
Author: User

Stack area: Mainly used for storing local variables , passing parameters , storing the return address of the function. . ESP always points to the top of the stack, the more data in the stack , the smaller the value of the ESP.

Heap area: Used to store dynamically allocated objects , when you use malloc and New to allocate, the resulting space is in the heap. Dynamically allocated areas of memory are provided with allocation information , so you can free and delete them.

Data area: Global, static, and constant are allocated in the data area, and the data area includes BSS (uninitialized data area) and initialization data area.

Attention:

1) heap to high memory address growth;

2) stack to low memory address growth;

3) heap and stack are opposite, there is a critical point between heap and stack, called stkbrk.

1 , a process in-memory mapping

Suppose you now have a program that has the following sequence of function calls:

Main (...)->; func_1 (...)->; func_2 (...)->; func_3 (...), that is: main function main call function func_1; function func_ 1 call function func_2; function func_2 call function func_3.

When a program is called into memory by the operating system , the mapping of its corresponding process in memory is as follows:

iOS Development variables and memory

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.