In OC, non-object variables are stored on the stack, objects are stored in the heap, and static memory is allocated when the program is compiled. This memory is allocated for the entire runtime of the program, and is mainly used to store static data, global data, and constants.
Stack area: During the execution of a function, storage units of local variables in the function can be created on the stack. When the function is finished, these storage units are automatically released. Stack memory efficiency is high, memory capacity is limited.
Heap area: OC objects are stored in the heap and are automatically released when the application count of the object reaches 0.