Skip to content
0:00 / 0:00

#malloc#memoryallocation#heap

Code for Game Developers - Anatomy of a Memory Allocation

Jorge Rodriguez

41K subscribers • 1 video on Hallway

YouTube
  • Recommended by 1 person: 1 in engineering communities.
  • Presented by Jorge Rodriguez, game developer
  • May be out of date. Uploaded 11 years ago, in an area where tools change fast.

Intermediate. Assumes working knowledge.

13K views11 years ago1 recommendation

Systems programmingGame developmentMemory managementPerformance and optimizationC

Jorge Rodriguez explains what happens during a C or C++ memory allocation and why game developers often avoid malloc.

This bonus video breaks down exactly what happens every time a C or C++ program allocates memory. We can see why it takes so freaking long, and thus why game developers tend to avoid malloc in favor of custom memory allocation routines. New video whenever I have time. Question? Leave a comment below, or ask me on Twitter: twitter.com/VinoBS

Why it's here

1 person recommends this

What people say. Recommended for understanding how memory allocation works under the hood and why custom allocators are used.

u/jackdbdin r/Zig • Recommends

On “What book can you recommend to learn zig?”

…For example: * bump allocator * bump allocator with expandable memory (aka arena allocator) * testing allocator (very useful when you are writing tests because it will scream at you when your code has memory leaks) Maybe write some tests that allocate some memory to see how to use them. And of course watch this excellent talk by Benjamin Feng: [video This talk about memory allocation by Jorge Rodriguez is also great: [video Also, you'll need to understand the different types of **pointers** in Zig, so have a look at Solving Common Pointer Conundrums by Loris Cro: [video As for some materials on stack, heap, etc, try googling something like "memory layout of a C program". I woul…

u/jackdbdin r/Zig • Recommends

On “What is a allocator anyway?”

Think about these questions: 1. how much memory to allocate? 2. when to allocate it? 3. what to do when memory allocation fails? The answers to these questions are platform and architecture specific, and since one of the design goal of zig is to be compilable for any architecture, it cannot answer these questions for you. It's up to you to define an allocation strategy (i.e. answer to the questions above). Zig defines an interface that you can implement to allocate/deallocate memory. And in order to cover common use cases, Zig also provides several implementations of that interface. But since Zig exposes such interface to you, you always have the option to allocate/deallocate memory howev…