HEAP
What is the HEAP ?
Heap is a memory region allocated to every program. Unlike stack, heap can be dynamically allocated.
The program can "request" and "release" memory from the heap whenever it requires.
This allocated memory is global. it mean that it can be accessed and modified from anywhere within a program. This can be done using pointers
to reference the dynamically allocated memory.
How to use ?
In C, stdlib.h
provides functions to work with the HEAP.
malloc()
, used to request the space memoryfree()
, used to release the space memory
Here is a code example :
Last updated