core practice · coding

Trace a program into process memory

Implement memoryMap() for this C-shaped program: static int requests; int main() { char *buffer = malloc(4096); int count = 0; serve(buffer, &count); free(buffer); }. Return executable, stack, heap, pointer, and process strings. Each must be a distinct explanation of at least six words that names its storage, lifetime, ownership, or loading mechanism.

The mechanism

A pointer is a typed interpretation of an address inside a process virtual address space. Stack frames follow call lifetimes, heap allocations follow explicit or runtime-managed ownership, and the loader maps code and data into a process before execution begins.

Study Program Memory Model

Expected evidence

A five-part causal trace distinguishing the executable image, stack frame, heap allocation, pointer value, and running process virtual address space.

Try this drill in the practice workspace →

Hints when you need them
  • Separate the pointer variable from the allocation it references.
  • Describe what the loader and operating system create before main runs.

Watch for these mistakes

  • Saying a pointer lives on the heap when only the allocation it references is on the heap
  • Equating virtual addresses with stable physical memory locations
  • Ignoring ownership and lifetime when memory crosses thread, callback, or process boundaries

Check the sources

Browse all practice briefs