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.

Optimizing code using the Process View

The Process View collects information that you can use to optimize your code, so that the application you are developing doesn't drain the battery of a BlackBerry device. Increased CPU, memory, and timer usage can drain device battery.

The Process View provides a summary of statistics for each process, including:

  • CPU usage
  • Total CPU
  • Current heap size
  • High water mark
  • Total allocations
  • Total wakeups

When a device is idle, none of the statistics for any process should change substantially over a short time. If you see that these statistics are changing while you're monitoring your app, you should review and improve your code.

You will need to make periodic updates in the Process View, which require a large amount of data to be transmitted using a USB cable, and it can have a noticeable impact on device performance. If you want to compare stats before, after, or during an operation, try one of the following methods:

  • Interrupt execution by clicking the stop icon to update the view, and then restart the application to carry out the tests before stopping again.
  • Turn on periodic updates temporarily, and then turn off the updates when the window is updated.

Disabling the battery charging animation

If the battery charging animation is distracting while examining application behavior, you can disable the animation by completing the following steps:
  1. On the BlackBerry device, click Options > Display > Screen Display.
  2. Scroll to the bottom of the screen.
  3. Show the keyboard (for devices without a physical keyboard).
  4. On the keyboard, type batt. An option to enable or disable the battery animation appears at the bottom of the screen. You may need to scroll down to see it.
  5. Select Disabled.
  6. Click Save and close Options.
  7. If a USB cable is connected, disconnect and reconnect it.

The battery animation is enabled again after you reset the device. If the battery animation is enabled, CPU usage is approximately 10%.

Open the Process View

  1. In Eclipse, start a debug session by clicking Click Window > Show view > Debug.
  2. Click Window > Show view.
  3. Expand the BlackBerry folder.
  4. Click BlackBerry Process View.
  5. When your application hits a breakpoint, click Refresh.

To suspend the debugger every 2 seconds and refresh the Process view, click Options and select the Live Update check box.

If you open the Process View without a debugger running, the view will be empty and an error is displayed. When you attached a debugger, the view is refreshed and the columns are created.

Specify Process View options

  1. In the Package Explorer, right-click a BlackBerry device application project.
  2. Click Debug As > BlackBerry Simulator.
  3. Click Window > Show View > Other.
  4. Expand the BlackBerry folder.
  5. Click BlackBerry Process View.
  6. Click OK.
  7. In the BlackBerry Process View, click Setup Options.

Process View options

Option Description
CPU utilization This option indicates increases in CPU activity for specific applications as changes occur in the state of the device and apps that are running.
Total CPU usage Total CPU usage since the process started.
Heap size Shows the size of all objects in RAM that are allocated within each running application's process, with changes shown over time. The size for a particular application increases as new objects are created and decreases as unreferenced memory objects are discarded.
Heap high water A memory marker that indicates the maximum level of heap memory usage.
Total allocations All memory allocations within the process, including memory objects, that were discarded.
Wakeups/sec The number of times per second that the application causes the device to wake up from standby mode. This column is not available if the debugger does not support the Process View.
Total Wakeups The total number of times that the application caused the device to wake up from standby mode since the process started. This column is not available if the debugger does not support the Process View.