Memory Tuning

Importing Data

  1. Start MindStudio Insight and click Import Data in the navigation tree on the left.
  2. In the File Explorer dialog box that is displayed, select the .db file to be imported, as shown in Figure 1.
    Figure 1 Importing data
  3. After the import is successful, the Leaks page is displayed.

Analyzing Memory

  1. Open the Leaks page to view the Function Stack Flame Graph and Memory Request/Release Line Graph & Memory Block Graph. For details about the leaks page, see "Memory Tuning" in MindStudio Insight User Guide.
  2. Click and drag the mouse to select the step 2 area in the Memory Request/Release Line Graph & Memory Block Graph and release the mouse button to zoom in on the step 2 area.

    As shown in Figure 2, when step 2 ends, there is still an unreleased memory block.

    Figure 2 Memory block that is not released
  3. In the Function Stack Flame Graph, the memory block is found to originate from a tensor object, which was allocated before the forward propagation starts, as shown in Figure 3.
    Figure 3 Tensor object
  4. In the code block marked with leaks_mem, the Memory Details Disassembly Diagram reveals a significant increase. The memory usage under the leaks_mem label first appears at 40 MB in step 1, as shown in Figure 4.
    Figure 4 Memory usage in step 1

    As shown in Figure 5, the memory usage under the leaks_mem label increases from 40 MB to 80 MB in step 2.

    Figure 5 Memory usage in step 2

    As shown in Figure 6, the memory usage under the leaks_mem label increases from 80 MB to 120 MB in step 3.

    Figure 6 Memory usage in step 3