From the course: Programming Foundations: Memory, Pointers, and Garbage Collection

Unlock the full course today

Join today to access over 25,200 courses taught by industry experts.

Allocating memory

Allocating memory

- [Instructor] The assigning of a piece of memory, a memory address, and reserving it to store a certain value, program, or process is called memory allocation. We already mentioned that we had two ways of allocation, static and dynamic. Static memory allocation is for compile time allocation and dynamic memory allocation is for runtime allocation. Dynamic memory allocation happens whenever we need to create new values on the heap. What happens is that a memory area gets selected to put their value in. The value gets written to the heap or it is reserved for certain purposes, and a variable on the stack holds the pointer to the element on the heap. This point to the element on the heap can be passed to other functions. The exact terminology for these principles differs per programming language. Also, allocating the memory is part of the memory management, and how this is done differs for different systems and languages.…

Contents