Data type heap
The heap data type is a portion of RAM dynamically allocated for each variable. At the same time, each variable can be called globally throughout the entire application, and not only in a separate thread as in stacks.
After the work is completed, all memory occupied by variables in the heap is freed. The heap size can be set when the application starts.
The disadvantage of the heap is that it works slower than the stack. For example, the last declared variables will be retrieved last and the system needs more time to find them. However, only the heap data type allows correct work with global variables and dynamically changing objects.