cool hit counter ios memory management - memory management scope_Intefrankly

ios memory management - memory management scope

To understand the scope of ios memory management, first I should also understand a few areas of memory


1, the stack area (stack) - automatically allocated by the compiler to release , to store the value of the function parameters, the value of local variables, etc.. 2, heap area (heap) - generally allocated by the programmer to release, if the programmer does not release, may be reclaimed by the OS at the end of the program Global variables and static variables are stored in one area, initialized global variables and static variables are in one area, uninitialized global variables and uninitialized static variables are in an adjacent area, and are released by the system after the program is finished. 4. Constants area - This is where the constant strings are placed. Released by the system at the end of the program. 5, program code area - store the binary code of the function body.

And two more bits of knowledge in passing

How does the system respond after application?

Stack. As long as the remaining space on the stack is larger than the requested space, the system will provide memory for the program, otherwise an exception will be reported indicating a stack overflow. Stack. The first thing you should know is that the operating system has a chain table that records free memory addresses. When the system receives a request from a program, it traverses that chain, looking for the first heap node with more space than the requested space, and then removes that node from the free node chain and allocates that node's space to the program. Since the size of the found heap node may not be exactly equal to the size of the request, the system will automatically put the extra portion back into the free link table.

What are the application size limits?

Stack: A stack is a data structure that extends to a lower address and is a contiguous area of memory. is the address of the top of the stack and the maximum capacity of the stack is predefined by the system, the size of the stack is 2M (some say 1M, in any case is a constant determined at compile time ) , if the requested space exceeds the remaining space on the stack, will prompt overflow. Therefore, less space can be obtained from the stack. Stack.Heaps are data structures that extend to high addresses, is a discontinuous memory region。 This is due to the fact that the system uses a linked table to store the free memory addresses, Nature is not continuous, And the direction of traversal of the chain table is from the low address to the high address。 The size of the heap is limited by the amount of virtual memory in effect on the computer system。 from this, it can be seen that..., Heaps get more flexible space, It's also bigger.。

A comparison of application efficiency?

Stack: automatically assigned by the system, faster. But the programmer has no control over it. Heap: is the memory allocated by new, generally slower, and prone to memory fragmentation, but the most convenient to use.

Ok now for the scope of ios memory management Only oc objects need memory management, non-oc objects (e.g. char, int, folat) do not need memory management

Reason. OC objects are placed in the heap, usually allocated and released by the programmer, if the programmer does not release them, they are reclaimed by the OS at the end of the program Non-OC objects are placed on the stack, and the stack system automatically manages

1、Introduction and manipulation of C string types
2、Springboot Essay 1 Autointroduction of configuration and startup mechanism
3、Python Chinese community open source project plans forward
4、EngineerCMS implements swaggerAPI automation documentation with beego
5、Uber under siege a onesided understanding of the sharing economy

    已推荐到看一看 和朋友分享想法
    最多200字,当前共 发送