Sorry about the red box, but we really need you to update your browser. Read this excellent article if you're wondering why we are no longer supporting this browser version. Go to Browse Happy for browser suggestions and how to update.

Locating memory allocation problems

Memory allocation problems can cause the BlackBerry Java Virtual Machine to run out of flash memory, and the BlackBerry device to reset.

Viewing memory statistics

You can use the Memory Statistics tool with the Objects tool to find memory allocation problems. The Memory Statistics tool retrieves information about the memory usage of your application, and identifies the number of objects stored in memory. The Objects tool displays detailed information about each object.

Column

Description

# objects

The number of objects that are currently stored in memory.

Bytes in use

The amount of memory that is used by objects.

Allocated

The total amount of memory that is allocated to the BlackBerry Java Virtual Machine.

Free

The amount of memory that is available.

Row

Description

Object handles

The number of object handles that are stored in memory.

RAM

The amount of RAM usage.

Flash

The sum of the objects that are stored in flash memory.

Transient objects (flash)

The number of transient objects that are stored
in flash memory.

Persistent objects (flash)

The number of persistent objects that are stored
in flash memory.

Code modules (flash)

The number of code modules that are stored
in flash memory.

View statistics to locate memory allocation problems

On the Window menu, click Show View > Other.

Expand the BlackBerry folder.

Click BlackBerry Memory Statistics View.

Click OK.

Display objects that are stored in memory to locate memory allocation
problems

Specify two or more breakpoints in your code.

On the
Run menu, click
Debug As > BlackBerry
Simulator or Debug As > BlackBerry
Device. The application runs to the first breakpoint.

Perform operations in the application that do not increase the
number of reachable objects. For example, create a new contact and then delete
it.

In the
Debug view, click
Suspend.

In the
BlackBerry Objects View, click
Perform garbage collection.

The
BlackBerry Objects View displays the number of
objects that have been deleted and added since the previous snapshot. If the
number of objects added is not the same as the number of objects deleted, you
might have a memory allocation problem.

To identify new objects, use the
Type,
Process, and
Location filter types in the
Objects View Options dialog box.

To save the contents of the
BlackBerry Objects View to a comma-separated
values (.csv) file, click
Save.

Find a memory allocation problem

Specify two or more breakpoints in your code.

On the
Run menu, click
Debug As > BlackBerry
Simulator or click Debug As > BlackBerry
Device. The application runs to the first breakpoint.

On the
Window menu, click
Show View > Other.

Expand the
BlackBerry folder.

Click
BlackBerry Memory Statistics View.

Click
OK.

In the
BlackBerry Memory Statistics View, click
Refresh.

Click
Snapshot.

Press
F8 to resume running the application. The
application runs to the second breakpoint.

Click
Refresh.

Click
Compare.

Repeat steps 1 through 11, setting breakpoints closer together
until they converge on the memory allocation problem.