


New - The process is in the stage of being created.Processes may be in one of 5 states, as shown in Figure 3.2 below.Key among them are the program counter and the value of all program registers.įigure 3.1 - A process in memory 3.1.2 Process State When processes are swapped out of memory and later restored, additional information must also be stored and restored.If they should ever meet, then either a stack overflow error will occur, or else a call to new or malloc will fail due to insufficient memory available. Note that the stack and the heap start at opposite ends of the process's free space and grow towards each other.Note that the stack is also used for function return values, and the exact mechanisms of stack management may be language specific. Space on the stack is reserved for local variables when they are declared ( at function entrance or elsewhere, depending on the language ), and the space is freed up when the variables go out of scope. The stack is used for local variables.The heap is used for dynamic memory allocation, and is managed via calls to new, delete, malloc, free, etc.The data section stores global and static variables, allocated and initialized prior to executing main.

