Garbage collection on a BlackBerry device
RAM garbage collection on a BlackBerry device
The BlackBerry® Java® Virtual Machine initiates a RAM garbage collection operation only when the BlackBerry JVM cannot
allocate an object because of a lack of space in RAM. The RAM garbage collection operation typically takes 500 to 600 milliseconds
to execute. The garbage collection operation removes any freshly allocated variables that are no longer referenced in RAM. To
make sure that the lack of a reference in RAM is a sufficient condition for removing the object, a RAM garbage collection operation
can only be performed when objects have not been paged out to flash memory.
Full garbage collection on a BlackBerry device
The full garbage collection operation executes for 1 second on average and should take less than 2 seconds to complete. The full
garbage collection operation performs the following actions:
•
It performs a RAM garbage collection operation.
•
It marks objects in flash memory that are no longer referenced or no longer persisted.
•
It releases any nonpersistent object handles in RAM and flash memory.
The system might initiate a full garbage collection operation in the following situations:
•
The BlackBerry® Java® Virtual Machine cannot allocate an object because of a lack of available space in RAM.
•
A process is about to exceed its currently allocated heap size.
•
The BlackBerry JVM cannot allocate a new object because the object handles are not available.
•
The BlackBerry device is idle.
Idle garbage collection on a BlackBerry device
Garbage collection does not occur every time that the BlackBerry® device idles. It occurs only when the system considers a
garbage collection operation to be beneficial for optimal system performance and maximized battery performance.
To improve performance without impacting the BlackBerry device user experience, the system attempts to perform the following
garbage collection operations when the BlackBerry device idles:
•
A full garbage collection operation can occur when the BlackBerry device idles for a relatively small amount of time.
•
A thorough garbage collection operation can occur when the BlackBerry device idles for a significant period of time.
Fundamentals Guide
Garbage collection on a BlackBerry device
27