analyze

Function Description

The analysis API provided by msLeaks supports memory leak analysis and custom inefficient memory identification.

  • Memory leak analysis

    This API provides offline analysis on memory leaks in a specified range, supports offline analysis for the dumped .csv files generated by msLeaks, and triggers an alarm when memory leaks in the specified range are detected. Currently, this function applies only to HAL memory leak analysis.

    Before using this API, you need to mark the specified range using mstx and start the user process using msLeaks to obtain the dumped .csv file. Then, you can use the API to input the .csv file to be analyzed, instrumentation information, and start index for offline leak analysis.

  • Custom inefficient memory identification

    This API supports custom parameter input to identify inefficient memory offline in the dumped .csv or .db file generated by msLeaks. You can flexibly set the memory block threshold, inefficient memory type, and temporary idle API interval based on the custom parameter specifications, thus accurately identifying inefficient memory in the dumped .csv or .db file.

    If the input .csv or .db file already has inefficient memory identification results, using the custom identification function will not remove them. The new identification results will be added instead. If you need to perform the custom inefficient memory identification function for multiple times, you are advised to back up the original file.

Function Prototype

analyze(analyzer_type: str, **kwargs):

Parameter Description

  • Memory leak analysis

    If the parameter is leaks, see check_leaks.

  • Custom inefficient memory identification

    If the parameter is inefficient, see check_inefficient.

Return Value Description

After the API is executed, the analysis result is displayed.

Example

1
2
3
4
5
6
7
8
9
import msleaks
msleaks.analyze("leaks", input_path="user/leaks.csv", mstx_info="test",start_index=0)

msleaks.analyze("inefficient",
		input_path="user/ineff.csv",mem_size=0,
		inefficient_type=["early_allocation","late_deallocation","temporary_idleness"],
		idle_threshold=3000
		)
# Use the actual path for input_path.