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