STACK: a main storage area of the "back-to-first-out" (LIFO), located in the stack segment, using the SS segment register to record its segment address. It has only one entrance, that is, the top of the current stack, and the top of the stack is a small end (low end), which is specified by the stack pointer register sp. The stack has two basic operations in the unit of words, corresponding to two basic commands: The push command in the stack and the pop command in the stack.
Stack Zone(Stack)-the compiler automatically assigns release, stores the parameter values of the function, and values of local variables. The operation method is similar to the stack in the data structure. That isToo much vomit. For example, when calling a function.
Heap Area(HEAP)-generallyProgramMembers are assigned to release the program. If the programmer does not release the program, it may be recycled by the OS at the end of the program. Note that it is different from the heap in the data structure. The allocation method is similar to the linked list. For example, the malloc Function
Global Zone(Static)-the storage of global and static variables is put together, and the initialized global and static variables are in one area, uninitialized global variables and uninitialized static variables are in another adjacent area. The program is released by the system.
Text Constant Area-The constant string is placed here and is released by the system after the program ends.
The initialized data segment (. Data) contains the global variables explicitly defined in the program and static variables.
Non-initialized data segments (. BSS) do not provide global variables and static variables that clearly define the initial values.
ProgramCodeArea (code segment)-stores the binary code of the function body.
Queue: first-in-first-out, eat too much.
Although the stack is called a connection, they still have a lot of difference. The connection is only due to historical reasons.
If you wantIn-depth study cThe best thing to do is to viewCompiled assemblyCode to view its specific operations, of course, this is only a personal research, if you want to know the celebration of various library functions, You can queryC Language Library source code(Classic and concise ).Read moreNow!
Generally, the compiler divides the memory into three parts:Static storage area, stack, and stack.
Static storage ZoneStores global and static variables,
Stack StorageCall function-related variables, addresses, etc,
Heap StorageDynamically generated variables in CIs released by the malloc and free operations.Storage spaceIn C ++, it refers to the functions of the new and delete operators.Storage Area.