1 / 41

Data structures and memory management on mobile devices

Data structures and memory management on mobile devices. Agenda. This course covers the following topics: Introduction to developing applications for mobile devices Methods of application development for mobile devices Introduction to GPS and Wi-Fi® technology on BlackBerry® smartphones.

charis
Download Presentation

Data structures and memory management on mobile devices

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Data structures and memory management on mobile devices © 2009 Research In Motion Limited

  2. Agenda • This course covers the following topics: • Introduction to developing applications for mobile devices • Methods of application development for mobile devices • Introduction to GPS and Wi-Fi® technology on BlackBerry® smartphones GPS Global Positioning System © 2009 Research In Motion Limited

  3. Agenda Introduction to push technology Data structures and memory management on mobile devices User interface design for mobile devices BlackBerry themes and animated graphics Security considerations for developing applications for mobile devices © 2009 Research In Motion Limited

  4. Data structures and memory management on mobile devices Objectives: Explain why memory management is important for mobile devices. Identify techniques to minimize memory usage. Identify data structures that minimize memory consumption. © 2009 Research In Motion Limited

  5. Data structures and memory management on mobile devices Objectives: Identify and describe the purpose of BlackBerry persistence model; MIDP record store; runtime store; File Connection API, and SQLite. Describe how to back up and synchronize data. API application programming interface MIDP Mobile Information Device Profile © 2009 Research In Motion Limited

  6. Memory management © 2009 Research In Motion Limited

  7. Memory management BlackBerry® Java® Virtual Machine: Manages memory usage on the BlackBerry smartphone Shares available memory between the BlackBerry smartphone applications and the BlackBerry® Java® Application © 2009 Research In Motion Limited

  8. Memory management Low memory issues: Java garbage collection automatically reclaims memory that the operating system no longer uses, and combines free memory into large blocks. If the BlackBerry smartphone runs out of SRAM space, the BlackBerry Java Virtual Machine swaps memory out to the flash memory. If flash memory is also full, then the BlackBerry Java Virtual Machine cannot perform this task effectively. SRAM static random access memory © 2009 Research In Motion Limited

  9. Memory management Disadvantages of the BlackBerry® Java® Development Environment: It requires a more advanced skill set. Java applications reside on the mobile device itself. © 2009 Research In Motion Limited

  10. Memory management Some techniques to minimize memory use: Use primitive data types. Do not depend entirely on the garbage collector. Avoid creating many objects quickly. Set object references to null when you are finished . Reuse objects. Move heavy processing to the server. © 2009 Research In Motion Limited

  11. Memory management The low memory manager: Handles memory resources on the BlackBerry smartphone when the available memory resources fall below a certain threshold Frees memory to provide more available memory on the BlackBerry smartphone © 2009 Research In Motion Limited

  12. Memory management Data structure selection defines how many object handles and how much flash memory a BlackBerry Java Application consumes. Considerations: Ensure that the data structure consists of the minimum possible number of objects. Use primitive data types instead of objects. String objects are as efficient as byte arrays. © 2009 Research In Motion Limited

  13. Memory management Object consolidation: The amount of flash memory on the BlackBerry smartphone determines the fixed number of persistent object handles that are available in the system. The data structure selection determines the rate at which the stored records exhaust the number of persistent object handles. A persistent object consumes a persistent object handle and an object handle. A transient object consumes only an object handle. © 2009 Research In Motion Limited

  14. Memory management To consolidate the object handles into one group: Use the net.rim.device.api.system.ObjectGroup class. The consolidated object handle is read-only. To change the object, first ungroup it. © 2009 Research In Motion Limited

  15. Memory management The garbage collector determines whether an object is reachable. The garbage collection system reclaims and reuses resources as it identifies and discards objects that a program no longer needs. Two types: RAM garbage collection Full garbage collection RAM random access memory © 2009 Research In Motion Limited

  16. Memory management RAM garbage collection: Removes unreferenced objects from RAM Initiates only when the BlackBerry Java Virtual Machine cannot allocate an object because of a lack of space in RAM Takes 500 to 600 milliseconds to execute © 2009 Research In Motion Limited

  17. Memory management Full garbage collection: Performs a RAM garbage collection operation Marks objects in flash memory that are no longer referenced or persistent Releases nonpersistent object handles in RAM and flash memory © 2009 Research In Motion Limited

  18. Memory management Full garbage collection is initiated when: 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 Java Virtual Machine cannot allocate a new object because the object handles are not available The BlackBerry smartphone is idle © 2009 Research In Motion Limited

  19. Memory management Idle garbage collection: Occurs only when the system calculates that a garbage collection operation is beneficial for optimal system performance and maximized battery performance Improves performance without affecting the BlackBerry smartphone user experience © 2009 Research In Motion Limited

  20. Data storage © 2009 Research In Motion Limited

  21. Data storage Data can be stored on a BlackBerry smartphone by: BlackBerry persistence model MIDP record store Runtime store File Connection API SQLite © 2009 Research In Motion Limited

  22. Data storage Access to memory: It inhibits applications from causing problems accidentally or maliciously in other applications or on the BlackBerry smartphone. Applications can write to the BlackBerry smartphone memory that the BlackBerry Java Virtual Machine uses. Custom applications can only access persistent storage or user data, or communicate with other applications through specific APIs. © 2009 Research In Motion Limited

  23. Data storage File systems and paths: BlackBerry smartphones include the following types of on-board memory: Internal flash (///store/home/user) Internal SD card (///system) microSD memory card (///SDCard) © 2009 Research In Motion Limited

  24. Data storage Persistent data storage: Persistable objects include String and Integer. The application that creates the data lets you share data between applications. Packages net.rim.device.api.system.PersistentStore net.rim.device.api.system.PersistentObject net.rim.device.api.util.Persistable © 2009 Research In Motion Limited

  25. Data storage Persistent data storage: To save an object, use a unique ID to add it to the persistent store. To be persistable, a data class needs to implement the Persistable interface. Each PersistentObject has a unique long key. ID identification © 2009 Research In Motion Limited

  26. Data storage Persistent data storage tasks: Create a persistent data store Store persistent data Retrieve persistent data Remove persistent data © 2009 Research In Motion Limited

  27. Data storage MIDP record storage: MIDP allows you to port an application across multiple BlackBerry smartphones that are compatible with Java® ME. Persistent data is stored as records in RecordStore objects. Each RecordStore object belongs to a single MIDlet suite. © 2009 Research In Motion Limited

  28. Data storage MIDP record storage tasks: Create an MIDP record store Add a record to a record store Retrieve a record from a record store Retrieve all records from a record store © 2009 Research In Motion Limited

  29. Data storage Runtime storage: BlackBerry smartphones use a runtime store as a central location in which BlackBerry Java Applications can share runtime objects. The runtime store is not persistent. When you restart the BlackBerry smartphone, the data in the runtime store is cleared. © 2009 Research In Motion Limited

  30. Data storage Runtime storage tasks: Retrieve the runtime store Add an object in the runtime store Replace an object in the runtime store Retrieve a registered runtime object Retrieve an unregistered runtime object © 2009 Research In Motion Limited

  31. Data storage • SQLite: • BlackBerry devices that run BlackBerry Device Software version 5.0 or later have the SQLite library integrated into the operating system and virtual machine. • The SQLite API enables you to develop applications that use the integrated SQLite database. • The net.rim.device.api.database package includes classes that enable you to work with SQLite. • Each SQLite database is stored in a single file.

  32. Data storage • SQLite best practices: • Use a SQLite database browser with the BlackBerry Smartphone Simulator. • Reduce the database size by using the vaccuum command. • Optimize SQLite database performance.

  33. Data storage Data management: The BlackBerry API set allows an application to persist data in multiple ways. BlackBerry Persistent Store APIs and MIDP RMS APIs ( JSR 37 and JSR 118) are available on all Java®-based BlackBerry smartphones. Stores data persistently to flash memory. Data persists even if the battery is removed. © 2009 Research In Motion Limited

  34. Data storage File connection APIs provide a traditional file system and support for saving data directly to the file system on the BlackBerry smartphone or to a microSD card. File package to access the file system for the microSD media card: javax.microedition.io.file File package to define the File Connection APIs: javax.microedition.io.file (two interfaces and three classes) © 2009 Research In Motion Limited

  35. Data storage Persistent store APIs: Designed to provide a flexible and robust data storage interface Save entire Java objects to memory without having to serialize the data first Retrieve the Java object from memory and process the information No size limit exists on a persistent store Do not provide a relational database model © 2009 Research In Motion Limited

  36. Data storage MIDP record management system APIs: Provide a simple record management system that lets you create a data store object and retain a series of records within that object First serialize data into a byte array format before storing it locally Do not provide inherent indexing or relationships between records RMS record management system © 2009 Research In Motion Limited

  37. Data storage • MIDP record management system APIs: • The size limit for a single RMS data store varies, based on the device software version; limits range from 64KB to 512KB. • An application can create multiple RMS data stores. • RMS APIs are part of the standard MIDP specification, so all BlackBerry smartphones that support MIDP also support the RMS APIs.

  38. Data storage Backing up and synchronizing data: The BlackBerry® Desktop Manager backs up and restores the application database at the same time as other BlackBerry smartphone databases. To synchronize data to remote data sources, build the synchronization logic into the BlackBerry Java Application. A BlackBerry Java Application connects to a computer-based application to send the data over a USB connection using the BlackBerry Desktop Synchronization APIs and the BlackBerry Desktop Manager. USB universal serial bus © 2009 Research In Motion Limited

  39. Data storage • Backing up and synchronizing data: • The BlackBerry® Enterprise Server includes functions for back up, restore, and synchronization • The implementation is the same as the BlackBerry Desktop Manager, but is wireless • The process saves BlackBerry Java Application data with the user account settings and the other BlackBerry device data that backs up

  40. Data storage • Backing up and synchronizing data: • The Synchronization Server SDK provides third-party developers the ability to develop custom data source connectors for the wireless synchronization between a BlackBerry smartphone and data repository. • The connectors ensure that when data records are updated on the server, the corresponding changes are pushed out to the local information stored on the BlackBerry smartphone. • The Synchronization Server SDK includes a dynamic link library that provides a connector for backup and restore functions.

  41. © 2009 Research In Motion Limited

More Related