Why does Matplotlib leak memory when generating many plots in a loop, and how do you prevent it?
Role: Data Scientist
Category: Data Manipulation (SQL/Python)
Difficulty: medium
Interview Round: Other
Overview: Asks why a Python script that creates many Matplotlib figures in a loop keeps growing in memory and how to stop it. Tests understanding of how Matplotlib manages figure lifetime, the pyplot and object-oriented interfaces, backend choice for batch rendering, and how to verify a fix.