Rate This Document
Findability
Accuracy
Completeness
Readability

Analyzing the Result

After the task is complete, the analysis result page is displayed, as shown in the following figure.

The Call Tree tab page lists the functions where memory leakage occurs. Take the main function as an example. You can view the memory leak information about the main function and the called functions, including the size and number of memory leaks of the main function.

On the Source Code tab page, you can accurately locate the code where memory leak occurs to facilitate code modification. In this example code, a memory leak occurs in the main function. The malloc function allocates a piece of memory but does not release it, as shown in the following figure.

To solve the leak problem of the main function, perform the following steps:

  1. Add the following code to the appropriate position to release the memory:
    free(p);
    p = NULL;
  2. Recompile and run the code, and use the tool to scan the code again.

  3. Confirm that the memory leak problem does not exist in the main function. Repeat the preceding steps to modify the functions that may have memory leaks.