Collection with Python Interfaces

The msLeaks tool supports customizing the memory collection range and items through the Python interfaces, enabling precise data collection and efficient analysis.

Customizing Collection Ranges

A Python script example is added. You can use the Python script to customize and set multiple collection ranges.

The example code is as follows:

1
2
3
4
5
import msleaks

msleaks.start()   # Start the collection.
train()           # train() is the user code.
msleaks.stop()    # Exit the collection.

Customizing Collection Items

You can customize collection items as required. Currently, only the device, level, events, and call_stack parameters can be set.

The example code is as follows:

1
2
3
4
5
6
import msleaks

msleaks.config(call_stack="c:10,python:5", events="launch,alloc,free", level="0", device="npu")
msleaks.start()   # Start the collection.
train()           # train() is the user code.
msleaks.stop()    # Exit the collection.