How would you detect a memory leak in a production system?
✅ Answer:
I would start by monitoring memory usage trends over time using application metrics and system level tools. A steadily increasing memory footprint without release is usually a strong signal.
Next, I would capture heap dumps or use profiling tools to identify objects that are not being garbage collected. From there, I would trace back to the code paths retaining those references.
After fixing the root cause, I would add monitoring and alerts to detect abnormal memory growth early in the future. Prevention through observability is just as important as the fix itself.