I finally found some wonderful information about the memory usage on the BlackBerry.
| Memory Management |
The BlackBerry® Java® Virtual Machine manages memory usage on the BlackBerry device. The BlackBerry JVM allocates memory, performs garbage collection, and automatically swaps data between SRAM and flash memory. The BlackBerry JVM must also share available memory between the BlackBerry device applications and the BlackBerry® Java Application. The memory capabilities represent the total amount of available memory, which is larger than the available working memory when all of the applications and associated application data exist on the BlackBerry device.BlackBerry "Device Memory"
BlackBerry® devices include the following types of memory:
Flash Memory Key Resources to Reserve
The BlackBerry operating system and all application modules are stored persistently in flash memory. When a BlackBerry device user turns on the BlackBerry device, the core operating system and the BlackBerry® Java Application modules use approximately 10 MB to 15 MB of flash memory, depending on the version. Flash memory can store the BlackBerry device user's email messages, organizer data, and other personal information, as well as the data that a BlackBerry Java Application stores in memory.
SRAM controls the transient data objects and runtime processes.
MicroSD Expandible Memory Card
The microSD card stores media files, documents, and persistent data from a
BlackBerry Java Application.
The persistent storage space that is available on the BlackBerry® device is a fixed amount of flash memory, typically in the range of 8 MB to 64 MB.
Persistent object handles
The handles that are assigned to each persistent object are consumed only by persistent objects. The amount of flash memory on the BlackBerry device determines the fixed number of persistent object handles in the system.
Each object and array of primitives has an object handle associated with it. The amount of flash memory
on the BlackBerry device determines the fixed number of object handles in the system.
And also this information about low memory conditions occurring on the system.
| Best practice: Minimizing memory use |
To minimize runtime memory, consider the following guidelines:
xxx8226; Use primitive types (such as int or Boolean) instead of objects (such as String or Integer).Managing low memory availability
xxx8226; Do not depend entirely on the garbage collector.
xxx8226; Avoid creating many objects quickly.
xxx8226; Set object references to null when you are finished using them.
xxx8226; Reuse objects as much as possible.
xxx8226; Move heavy processing to the server. For example, you can filter or sort data before sending it to the BlackBerry® device.
The low memory manager handles memory resources on the BlackBerry® device when the available memory resources fall below a certain threshold. The low memory manager attempts to free used memory to provide more available memory on the BlackBerry device. All applications, including BlackBerry® Java Applications, should work with the low memory manager to free as much memory as possible when the BlackBerry device is low on memory resources.Identifying low memory availability on a BlackBerry device
The following conditions can cause the low memory manager to attempt to free memory resources:
xxx8226; The amount of available flash memory on the BlackBerry® device falls below a certain threshold. The flash memory threshold depends on the amount of free RAM in the system. The flash memory threshold ranges between 400 KB and 800 KB.
xxx8226; The number of persistent object handles that are available on the BlackBerry device falls below 1000 persistent object
xxx8226; The number of object handles that are available on the BlackBerry device falls below 1000 object handles.
And finally this information regarding garbage collection by the JVM and essentially memory management and control of the system when in operation.
| 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:
xxx8226; It performs a RAM garbage collection operation.
xxx8226; It marks objects in flash memory that are no longer referenced or no longer persisted.
xxx8226; It releases any nonpersistent object handles in RAM and flash memory.
The system might initiate a full garbage collection operation in the following situations:
Idle garbage collection on a BlackBerry device
xxx8226; The BlackBerry® Java® Virtual Machine cannot allocate an object because of a lack of available space in RAM.
xxx8226; A process is about to exceed its currently allocated heap size.
xxx8226; The BlackBerry JVM cannot allocate a new object because the object handles are not available.
xxx8226; The BlackBerry device is idle.
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:
xxx8226; A full garbage collection operation can occur when the BlackBerry device idles for a relatively small amount of time.
xxx8226; A thorough garbage collection operation can occur when the BlackBerry device idles for a significant period of time.
This is also interesting to note, but apparently Aerize has been able to circumvent this or so it seems.
| Security considerations |
Access to memory
The BlackBerry® Java® Development Environment is designed to inhibit applications from causing problems accidentally or maliciously in other applications or on the BlackBerry device. BlackBerry applications can write only to the BlackBerry device memory that the BlackBerry® Java® Virtual Machine uses; they cannot access the virtual memory or the persistent storage of other applications (unless they are specifically granted access to do so). A BlackBerry® Java Application can only access persistent storage or user data, or communicate with other applications, through specific BlackBerry APIs. Research In Motion must digitally sign a BlackBerry Java Application that uses these BlackBerry APIs, to provide an audit trail of applications that use sensitive APIs.
I believe that this is the reason why Aerize only works when you reinstall an application because Aerize cannot "break into" the already installed persistent application storage in the flash memory section of the device memory that applications are installed into apparently.