Save this video free

ECE344 Fall 2026 (Sec 1) Lec 28 - Basic Memory Allocation

Jon Eyolfson · 57:27 · Watch on YouTube

Part of University of Toronto ECE 344. See all 26 lectures and search them

These notes were made with YouTube Collector. Paste any YouTube link and get the same: a summary, chapters and a searchable transcript.

Overview

Jon Eyolfson explains how C library allocators subdivide the kernel’s 4 KiB pages into dynamically allocated blocks, contrasting static and stack allocation with heap-based malloc and free. He develops a bump allocator, then a free-list design using headers, footers, 16-byte alignment, fit strategies, splitting, and coalescing, before connecting glibc allocations to brk and mmap and reviewing common memory errors.

Key takeaways

Chapters

0:00 Kernel Pages and the Need for malloc
8:38 Static Allocation, Data, and BSS
10:48 Stack Allocation and Returning a Local Address
18:45 Dangling Stack Pointers and Heap Lifetimes
25:30 Bump Allocation and Its No-op free
32:30 Why Variable-size Heap Allocators Fragment
36:30 Free-list Blocks, Boundary Tags, and Alignment
44:15 Best Fit, Worst Fit, and First Fit
51:30 Splitting Blocks and Coalescing Free Neighbors
53:48 How glibc Uses brk and mmap
56:07 Overcommit, Allocation Bugs, and Memory Tools

Keep these chapters and the full searchable transcript in your own library.

Transcript excerpt

6:49 Alrighty, welcome back to operating systems. We got basic memory allocation today. Fun. So, let's get into it. So, recall for the kernel, the kernel is really dumb right now. It just is handing out whole pages at a time. We saw in lecture 11 that BRK system call that is growing the heap in our user programs. How the colonel implemented it pages implement or m map that asks for pages from the kernel. What does the kernel do? Gives out pages. Giving out pages is easy. It's just a free list of pages. One page is as good as any other. They're just 4 kilobyte pages at a time. And we discussed in the last lecture what happens when frames run out. When we cut run out of memory, well, we pick

7:38 pages to evict to disk. Or we could just run out of memory killer and just randomly kill a process and free all of its physical memory. But real programs, have you ever asked for a page before this course? Probably not. You probably asked for like a 100 bytes at a time or some other number, not pages. So something has to cut the pages into smaller chunks and or pieces and take the pieces back once you're done with them. That's maloc and free. And today is how we actually would implement it. So this would be in the C library, not the kernel. But you could imagine the kernel needs to use some memory itself. And everything would also apply to the kernel as well if it was to

8:26 ask uh to use memory as well because if you're in the kernel you don't have maloc and free because well you don't have the C standard library. So simplest allocate or simplest strategy

This is the start of the transcript. Save this video free for the whole transcript, searchable and time-coded.

In this course

Related notes

Summary, takeaways, and chapters were generated by AI from the video's transcript and may contain errors. The video belongs to its creator, Jon Eyolfson.

Want the full transcript?

Save this video in YouTube Collector to get its complete searchable transcript, your own AI summaries, and a library that keeps every video you collect in one place.