Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Fix OutOfMemory Errors in an application

by Retired ‎02-16-2010 10:42 AM - edited ‎02-18-2010 11:04 AM (4,239 Views)


This article applies to the following:

  • BlackBerry® wireless devices based on Java™
  • BlackBerry Java Development Environment (JDE)


An OutOfMemory error indicates that the application cannot allocate enough memory to execute properly. This situation normally occurs when there are too many unused objects that have accumulated and that have not been de-allocated by the garbage collector. For a multi-threaded application, threads that have finished their execution cycle might still be holding on to the memory and might not have been destroyed by the garbage collector.

To detect the cause of OutOfMemory errors

  1. Insert a break point at the line where the Runtime Exception occurs.
  2. Run the application.
  3. When the application hits the break point, click the View menu and select Memory Statistics. The window that appears shows the memory statistics of the application at the break point. These statistics indicate where the application may be using most of the allocated memory.
  4. If it is suspected that the application may be running out of memory because the garbage collector may not have de-allocated some objects, click on the View menu and select Objects.
  5. In the window that appears, click Refresh to view the list of objects that are alive at the break point in the application. If some of the objects in the list should be de-allocated, set them to Null in the code. The garbage collector will realize that these objects are no longer referenced and will de-allocate them.
  6. Select Threads from the View menu if it is suspected that some threads may be holding on to the memory even after they have been de-allocated.

Additional Information

Click the links below to see images of the tools described in this article:

Memory Statistics Tool

Objects Tool

Users Online
Currently online: 16 members 1,586 guests
Please welcome our newest community members: