Python Trace Collection
The msLeaks tool can collect trace data of Python code through Python interfaces and align the data with memory events on a unified timeline. This helps optimization personnel quickly associate memory events with full-link code and accurately locate problems.
Procedure
- Python interfaces are added to the msLeaks tool to enable and disable the Tracer function. Python code executed between start and stop will have its trace data written to the specified path.Code example:
1 2 3 4 5
import msleaks msleaks.tracer.start() # Enable the Tracer function. train() # train() is the user code. msleaks.tracer.stop() # Disable the Tracer function.
- After the execution is complete, a file named python_trace_{TID}_{timestamp}.csv is generated. For details about the file, see Output Description.
Parent topic: Memory Collection