Opening Scenario

Two bugs, same team, same week.

Bug A — the Python service. A background worker processes messages from a queue. On Monday it uses 400 MB. By Friday it's at 6 GB and the on-call SRE restarts it. Nothing crashes. Nothing errors. Memory just keeps climbing. You check: Python has a garbage collector. So how is this possible?

Bug B — the C++ service. A trading adapter that was rock-solid for six months suddenly segfaults in production. The stack trace points into a Session destructor. You read the code: a callback held a raw pointer into a Session; the Session was destroyed, but the callback ran later and dereferenced garbage.

Both are "memory bugs." Both have completely different causes. If you cannot tell them apart, you will spend days fixing the wrong problem.


Question Progression

Q1: What is the actual difference between a leak and a dangling reference?

Question: Both bugs involve memory behaving badly. What, in mechanical terms, distinguishes them?

In the full tutorial

  • When to Reach for This

Glossary history

Click dotted jargon to save explanations here.