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 - Python Tutorial
From the course: Programming Foundations: Memory, Pointers, and Garbage Collection
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.…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
What is memory?3m 43s
-
(Locked)
Why do we need to manage the memory?3m 19s
-
(Locked)
Stack memory3m 17s
-
(Locked)
Heap memory3m 39s
-
(Locked)
Heap vs. stack memory6m 47s
-
(Locked)
Allocating memory1m 49s
-
(Locked)
Deallocating memory1m 53s
-
(Locked)
Garbage collection6m 50s
-
(Locked)
Actual removing or sweeping2m 48s
-
-
-
-
-