Check runtime resource usage from inside the process.
Section: Profiling and Memory
Inspect process memory and CPU with psutil
python
python
import os
import psutil
process = psutil.Process(os.getpid())
print(process.memory_info())
print(process.cpu_percent(interval=1.0))Explanation
Requires the third-party `psutil` package, but it is extremely useful for production debugging and local diagnostics.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Profiling and Memory
Track memory allocations with tracemalloc
Capture memory allocation snapshots.
Profile a script with cProfile
Collect function-level runtime statistics.
Profile code inside Python
Wrap a hot path in cProfile and print stats.
Print the current exception traceback
Dump the active exception traceback in an except block.