Architecture in Motion · Episode 018

Java Memory Leaks: Finding Retained Cart Sessions and Bounding Cache Growth

Checkout slows again after every restart because a long-lived map keeps retaining abandoned cart sessions.

Illustrative failure model. No live payment, broker, database, or JVM is connected. Counts and timelines are teaching values, not benchmark results.

Check your understanding

Why can GC retain a cart after its business session expired?

What this model does and does not prove

Prove unwanted retention through root paths, then bound cache size and lifetime while keeping orders durable.

Every step describes a constructed scenario. These states do not replace load tests, fault injection, provider contracts, JVM recordings, or durable transaction checks. Previous and Reset rebuild the teaching state; they never roll back real business operations.