Memory Partitioning in IOS

Source: Internet
Author: User

1 About Ram ROM

We know that the RAM type does not have a power-down capability (i.e., a lost power data is all gone), so the app is usually stored in a memory card (Flash) or ROM. RAM is accessed much faster than memory card (Flash) or ROM.

2 when launching an app

To speed up the program execution, the system copies the open app from Flash or ROM to memory (RAM) and executes the code from inside the memory. Another reason is that the CPU cannot read instructions directly from the memory card (flash driver required, etc.).

3 Memory partitions: can be divided into 5 zones

1), stack (stack)-this is generally done by the compiler, will save some local variables, function jump address, site protection and so on

2), heap area (heap)-typically managed by programmers, such as ALLOC application memory

3), Global Zone (static)-the storage of global variables and static variables is placed in a block, initialized global variables and static variables in an area, uninitialized global variables and uninitialized static variables in another area adjacent. -The system is released after the program finishes. Note: The global zone can also be divided into uninitialized global zones:. BSS segment and initialize Global zone: Data segment. Example: int A; uninitialized. int a = 10; initialized.

4), constant area-constant string that's where it's placed.

5), code area-store code, that is, the 2nd app will be copied here.

4 Programming note

When an app launches, the code area, the constant area, and the global size are fixed, so pointers to these areas do not cause a crash error. While the heap and stack areas are constantly changing (heap creation destruction, stack bounce pop-up), so when using a pointer to the memory in these two areas, it is important to note whether the memory has been released, otherwise it will cause program crashes (very common in programming).

As shown: The code area is stored at a low address, and the stack area is stored at a high address.

Memory Partitioning in IOS

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.