Distribution process memory space

In the von Neumann architecture, a process must have: code segment, stack segment, the data segment.

The process virtual address space illustrated as follows:

Stack segment:

  1 provide storage for local variables inside a function.

  2. When a function call, stored "Process Activity Log."

  3. as a temporary storage area. When computing a long arithmetic expression, you can be part of the calculation result onto the stack.

Data segment (static memory):

  Including the BSS (Block Started by Symbol) data segment. BSS segment storage initialized or uninitialized global variable to 0, a static variable, embodied as a placeholder, the data segment is not allocated to the space, but the data size of the recording space required . Data storage segment through global and static variable initialization.

Snippet:

  Also called text segment. Executable instructions stored; may also contain a constant read-only variables, such as string constants and the like.

  Like the stack segment can grow automatically as needed, the data segment is also a target for the completion of this work, this is the heap. Heap area is dynamically allocated memory space used by the application malloc function, with the release of free function. calloc, realloc, and the like malloc: Returns a pointer to the former prior to the allocated memory contents are cleared to zero; the latter changing the size of a memory block pointer points, can expand and shrink, it is often the memory copy elsewhere the new address is then returned.

 

Guess you like

Origin www.cnblogs.com/lxy-xf/p/11075239.html