The diagram shows a framework for how to organize memory in a typical C + + program. The instructions in the program (which are stored at the bottom level) and global variables are often stored statically (static area), which is located at the beginning of the near machine address space where the address number is smaller. The amount of memory allocated in the zone does not change during program operation.
The highest address area in memory represents the stack area. When your program calls a function or method, the computer creates a new stack frame in the memory area. When the function returns, the created stack frame is revoked, freeing the memory for the stack frame required for subsequent function calls.
The area of memory between the stack area and the static zone is called the heap area. This area is useful when the program is running with more memory requested.
The temporary variable for the inline function exists on the stack of main, which is equivalent to the temporary variable of main.
C + + Program design basics, programming abstraction and algorithm strategy
Memory layout------C + + programming fundamentals, programming abstractions and algorithmic strategies