Go language memory storage model (for executable programs)

Insert picture description here

Code area

Receiving computer instruction code 只读area, 共享, 无法操作, .

Data area

  1. Initialize the data area
  2. Uninitialized data area
  3. Constant area

Heap area

The heap area stores things that allow users to access at will, generally storing videos, pictures, models, texts, etc., strings, slices, maps, new functions, etc.

Stack area

Stack area to store function information and local variables

Storage principle: first in, last in, last in, first out.

note

  1. The heap area is much larger than the stack area
  2. The stack area generally stores data variables of a known size, and the size of map slices etc. needs to be appended, so the size is undetermined.
  3. Store from low address to high address
  4. Data area generally refers to global variables
  5. The lowest address is not the code area, 0-255 is occupied by the system. Similarly, the highest is not the stack area, but the registry
  6. The stack area is stored from high address to low address
  7. There is a gc garbage collection mechanism in the stack area, which will maintain itself

Guess you like

Origin blog.csdn.net/KaiSarH/article/details/108576959