The peak, not the sum
transcript
A job allocates and frees memory. It uses memory in bursts, not all at once. Add up everything it allocated. Is that the memory it needs? Let us count a small case. Four cells, four events, nothing hidden.
Allocate four cells. Free four cells. Allocate four again. Free four again. The allocations sum to eight cells. But never more than four are live.
The running total goes four, zero, four, zero. The peak is four cells. It never rises above four, at any moment. The sum, eight, counts memory that was freed. Space is the peak.
The peak is the highest live total. The sum adds memory that was already freed. Plan the machine for the peak. A machine that fits the peak fits the whole job.
List the allocations and frees in order. Keep a running total. Add each allocation. Subtract each free. Report its highest value. Use a wide counter for large sizes.
Space is the peak. Full breakdown in the lecture.