Back to Developers
Developerspythonmemory-managementdebugging
Python Memory Leak Detector
Detects memory leaks and performance bottlenecks in Python code using static analysis.
Use Case
Use this prompt when debugging long-running Python processes or background workers that show increasing memory usage over time.
AI Prompt
Act as a Senior Python Engineer. Analyze the provided Python code block for potential memory leaks, unclosed resources, inefficient garbage collection patterns, or heavy memory consumption. Provide alternative code that optimizes memory footprint, handles resources safely with context managers, and explain the changes. Code: [insert Python code here].
How to Use
- 1Copy the suspect Python function or class.
- 2Paste the code into the placeholder.
- 3Analyze the refactored code and explanations provided by the model.
Example Output
Analysis of your Python script: I found a memory leak in the handle_connections function because file descriptors were opened inside a loop without being closed. I refactored the function to use the context manager with open to guarantee closure.
Related Prompts
View AllGit Conflict and Command Resolver
Resolves complex git conflicts, detached heads, and state disasters with safe, step-by-step terminal commands.
gitversion-controldebugging
View Prompt
Interactive Root Cause Debugging Assistant
Acts as an interactive debugger to diagnose complex stack traces, error messages, and state bugs.
debuggingtroubleshootingerrors
View Prompt
Production Debugging Assistant
Debug production issues with limited logs and incomplete information.
debuggingproductionincident
View Prompt