0Pricing
C++ Academy · Lesson

Coroutine Frame Allocation

Reason about coroutine frame allocation and lifetime.

Where State Lives

Local variables in a coroutine survive across suspensions. They cannot live on the stack — the function returns between suspensions. Instead, they live in a heap-allocated coroutine frame.

What the Frame Contains

The frame holds:

  • The coroutine s parameters
  • The promise object
  • Local variables that live across suspensions
  • The resume and destroy function pointers

All lessons in this course

  1. Coroutine Concepts co_await co_yield co_return
  2. Implementing a Simple Generator
  3. Async Tasks and Awaiter Types
  4. Coroutine Frame Allocation
← Back to C++ Academy