Fix a Memory Leak in a Long-Running Dasher Location Consumer

Last updated: November 29, 2026

Quick Overview

A service consuming Dasher GPS pings to feed ETA predictions grows in memory until it is killed every few days. Explain how you would find the leak and implement a bounded cache of last-known locations with both a size limit and a time-to-live.

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

0

0

0 solved


A service consuming Dasher GPS pings to feed ETA predictions grows in memory until it is killed every few days. Explain how you would find the leak and implement a bounded cache of last-known locations with both a size limit and a time-to-live.

DoorDash processes a constant stream of Dasher location updates, and unbounded per-key state in a consumer is a common way such services fail. The interviewer checks a structured debugging approach (measure, find growth, confirm root cause) and a fix that bounds memory without hurting read latency.

What the Interviewer Expects
  • Confirm the leak with memory metrics over time and correlate with traffic
  • Use heap snapshots (tracemalloc or a profiler) to find the growing structure
  • Identify unbounded per-key dictionaries and histories as the cause
  • Bound the cache by size and by age
  • Make eviction amortized O(1)
Key Topics to Cover
memory and performance
caching
LRU and TTL
profiling
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 choose the TTL and max entries?
  • What if the leak is in a C extension or native library instead of Python objects?
  • How would you alert before the process is killed?
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
  • Diagnose: memory grows steadily, restarts fix it temporarily.
  • Fix: update(dasher_id, lat, lng) and get(dasher_id) with at most max_entries and entries older than ttl treated as missing.
  • ...
High-Level Design

First prove it is a leak, not a working set that is simply large: plot RSS against active Dashers. Then take two tracemalloc snapshots an hour apart and compare by line; the top growth is usually a ...


Submit Your Answer
Markdown supported