How would you investigate memory leaks in a Python application?
- Manually inspect each variable in the code to find memory leaks.
- Use a memory profiler like memory_profiler to track memory usage over time.
- Use the psutil library to monitor CPU usage and infer memory leaks.
- Use the timeit module to measure execution time and find memory leaks.
To investigate memory leaks in a Python application, you can use a memory profiler like memory_profiler, which tracks memory usage over time, helping you identify areas of concern. Manual inspection (Option 3) is impractical for large codebases, and psutil (Option 2) primarily focuses on CPU usage. The timeit module (Option 4) measures execution time, not memory usage.
Loading...
Related Quiz
- How would you ensure that a piece of code in a module is only executed when the module is run as a standalone program and not when it is imported?
- A method inside a class that does not access or modify class-specific data is often marked as a _______.
- In type hinting, if a function is expected not to return any value, the return type should be hinted as _______.
- In Python, a multi-line string can be defined using _______ characters.
- If you have a function named fun inside a module named mod, how can you import it directly?