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 |
number of objects that are currently stored in memory |
Bytes in use |
amount of memory that is used by objects |
Allocated |
total amount of memory that is allocated to the Java® Virtual Machine |
Free |
amount of memory that is available |
Row |
Description |
|---|---|
Object handles |
number of object handles that are stored in memory |
RAM |
RAM usage |
Flash |
sum of the objects that are stored in flash memory |
Transient objects (flash) |
number of transient objects that are stored in flash memory |
Persistent objects (flash) |
number of persistent objects that are stored in flash memory |
Code modules (flash) |
number of code modules that are stored in flash memory |
View statistics to locate memory allocation problems
Find a memory allocation problem
- Specify two or more breakpoints in your code.
- On the Run menu, click Debug As > BlackBerry Simulator. 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.