Memory & GC
Reveal answer and reasoning
Place a bounded admission boundary before reading or materializing a large payload where the protocol permits. If waiting callers are allowed, bound their count or ensure their retained state is small and separately budgeted. A semaphore can limit active work while still allowing an unbounded number of WaitAsync callers, so the surrounding acceptance policy matters. Upstream servers, connection buffers and client behavior also contribute to the real system budget.
Choose an explicit policy for a full boundary: wait with a deadline, reject with a defined response, or drop only where the business contract permits loss. Cancellation must remove or finish the correct ownership path; signaling a token is not enough if the queued item or continuation still retains the payload. Return pooled buffers only after consumers stop, including failure and cancellation paths.
A request may own the original body, a decompressed representation, a parsed object graph and a serialized output at the same time. A payload-size estimate multiplied only by request count can therefore substantially understate the live set. Streaming helps only when downstream stages do not rematerialize the complete data. Pool capacity and native-library buffers add further owners beyond the logical payload.
Replicas multiply per-process baselines and pools. Scaling out can reduce active work per instance while increasing total retained idle capacity across the fleet. Conversely, one hot partition can overload a single replica even when the fleet average looks safe. Measure per-instance and aggregate behavior, and include the slowest realistic downstream dependency rather than assuming ideal service time everywhere.
What a strong answer covers
- A bounded channel does not bound memory held by waiting producers.
- Acquire a bounded admission lease before large payload allocation.
- More replicas multiply per-process pools and baselines.
Common pitfall
Calling a pipeline memory-bounded merely because its channel capacity is bounded while producers hold payloads outside it.
Follow-up questions
- Where do waiting producers retain state when admission is full?
- How do per-process pools affect aggregate memory across replicas?
Self-review
Choose what to revisit. These marks are your own assessment and are separate from lesson completion.