PreviousNext

View statistics to locate memory leaks

Use the Memory Statistics tool with the Objects tool to find memory leaks. Begin by using the Memory Statistics tool to retrieve information on your application's memory usage. The Memory Statistics tool identifies the number of objects in memory, while the Objects tool displays detailed information for each object.

The Memory Statistics tool displays the statistics on the number of objects and bytes in use for object handles, RAM, and flash memory.

Find memory leaks

The Memory Statistics pane has the following columns and rows.
Column
Description

# objects

displays the number of objects that are currently in memory

Bytes in use

displays the amount of memory that is used by Java® objects

Allocated

displays the total memory that is allocated to the VM

Free

displays the memory that is available

Row
Description

Transient objects

displays the number of transient objects in flash memory

Persistent objects

displays the number of persistent objects in flash memory

Code modules

displays the number of code modules in flash memory

Flash

displays the sum of the other three rows

Find a memory leak

    1. Set two or more breakpoints in your code.
    2. Open the BlackBerry® IDE.
    3. On the Debug menu, click Go. The application runs to the first breakpoint.
    4. In the main window, on the View menu, click Memory Statistics.
    5. In the memory statistics pane, click Refresh.
    6. Click Snapshot.
    7. On the Debug menu, click Continue. The application runs to the second breakpoint.
    8. In the memory statistics pane, click the Refresh tab.
    9. Click Compare to Snapshot.
    10. Repeat steps 1 through 8, setting breakpoints closer together until they converge on the memory leak.

Save the contents of the pane to a .csv file

Contents are saved as they are displayed.

    1. In the memory statistics pane, click Save.
    2. Select a location and type a name for the file.
    3. Click Save.

Related topic


   BlackBerry