Data segment

Historically, to be able to support memory address spaces larger than the native size of the internal address register would allow, early CPUs implemented a system of segmentation whereby they would store a small set of indexes to use as offsets to certain areas.

This distinction grew from early systems holding their main program in read-only memory such as Mask ROM, EPROM, PROM or EEPROM.

It is managed by malloc, calloc, realloc, and free, which may use the brk and sbrk system calls to adjust its size (note that the use of brk/sbrk and a single heap segment is not required to fulfill the contract of malloc/calloc/realloc/free; they may also be implemented using mmap/munmap to reserve/unreserve potentially non-contiguous regions of virtual memory into the process' virtual address space).

The set of values pushed for one function call is termed a "stack frame".

With large address spaces and virtual memory techniques they tend to be placed more freely, but they still typically grow in a converging direction.

Some interpreted languages offer a similar facility to the data segment, notably Perl[1] and Ruby.

This shows the typical layout of a simple computer's program memory with the text, various data, and stack and heap sections.