Build a Fixed-Size Object Pool With an Intrusive Free List

Last updated: November 29, 2026

Quick Overview

Implement a pool that preallocates N slots for request objects in a high-QPS frontend server, hands them out and takes them back in O(1) using a free list stored inside the unused slots, and detects double frees.

Google
Software Engineering Fundamentals
Software Engineer
Google
November 29, 2026
Software Engineer
Technical Screen
Software Engineering Fundamentals
Medium

0

0

0 solved


Implement a pool that preallocates N slots for request objects in a high-QPS frontend server, hands them out and takes them back in O(1) using a free list stored inside the unused slots, and detects double frees.

Latency-sensitive Google servers such as ads serving avoid per-request heap allocation to cut allocator contention and GC or fragmentation pauses. The interviewer checks that you can implement the classic free-list trick and reason about safety bugs like double free and use after free.

What the Interviewer Expects
  • Preallocate storage and keep a free list for O(1) acquire and release
  • Store the next pointer inside free slots instead of a side structure
  • Detect double free and foreign handles
  • Decide what happens when the pool is exhausted
  • Explain when a pool helps and when it hurts
Key Topics to Cover
object pooling
free list
memory allocation
latency
use after free
How to Approach This
  1. Apply SOLID principles. Single Responsibility makes code testable, Open/Closed makes it extensible.
  2. Choose data structures based on access patterns, not familiarity.
  3. Prefer immutable data and message passing over shared mutable state for concurrency.
  4. Design APIs with RESTful conventions, versioning, meaningful errors, and pagination from day one.
Possible Follow-up Questions
  • How would you make this thread safe without one global lock?
  • How do generation counters catch use after free?
  • How does this compare to tcmalloc's per-thread caches?
  • What happens to memory if a burst grows the pool and traffic drops?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice System Design Problems
Sample Answer
Requirements
  • ObjectPool(capacity, factory) builds capacity objects up front.
  • acquire() returns a handle (index, generation) in O(1); raises PoolExhausted when empty.
  • get(handle) returns the objec...
High-Level Design

The free list is a singly linked list threaded through an array next_free, where next_free[i] is the index of the next free slot and -1 ends the list. Acquire pops the head; release pushes. In C...


Submit Your Answer
Markdown supported