Memory & GC
Reveal answer and reasoning
A pinned pool can amortize allocation and avoid repeated movement constraints on ordinary storage, but it retains memory even when traffic falls. Bound count and capacity, track leases in flight, and return buffers only after native consumption ends. If a pool grows during a burst, specify whether and when unused capacity can shrink. A pool with no maximum simply replaces repeated allocation pressure with high-water-mark retention.
For an interview, draw four separate concepts: the managed owner, the pin or allocation-pinned storage, the native consumer and the completion signal. Explain which event permits each resource to be released. Discuss how an error before native acceptance differs from an error after acceptance. A strong answer protects correctness first, then proposes a representative benchmark for throughput, pause behavior and retained memory under the expected concurrency.
Move the buffer write after Free in the portable program and explain why managed indexing remains valid while the buffer is still owned. Then explain why the same conclusion would not permit using a previously obtained native pointer after its pin lease ended. Reachability, managed access and raw-address validity are different questions.
In the region scenario, compare pinning an existing SOH object conceptually with allocating the POH buffer. Remove the POH owner's root and collect only Gen 0, then Gen 2. Finish with a cancellation timeline for a native upload: allocate, pin, submit, cancel request, receive completion acknowledgement, unpin and return to pool. Identify the exact point at which reusing that storage becomes safe.
What a strong answer covers
- Pinning an existing object does not migrate it to POH.
- A pointer lease must end after native consumption, not merely after submission.
- POH objects remain collectible when no strong owner remains.
Common pitfall
Claiming that pinning an existing array moves it to POH, or freeing a pin before asynchronous native consumption ends.
Follow-up questions
- What acknowledgement permits releasing a pin after cancellation?
- Can generation2 alone distinguish POH from other storage?
Self-review
Choose what to revisit. These marks are your own assessment and are separate from lesson completion.