PROG 38448 Mobile Java Application Development PROG 38448 Mobile Java Application Development Memory and Memory Issues Data Storage.

Slides:



Advertisements
Similar presentations
Bruce Scharlau, University of Aberdeen, 2012 Data storage options for mobiles Mobile Computing.
Advertisements

Java Card Technology Ch04: Java Card Object
Paging: Design Issues. Readings r Silbershatz et al: ,
Module R2 CS450. Next Week R1 is due next Friday ▫Bring manuals in a binder - make sure to have a cover page with group number, module, and date. You.
J2ME 25 July Overview  What is J2ME?  The CLDC and CDC configurations  MIDP and MIDlets  Development Tools  Demonstrations.
UNDERSTANDING JAVA APIS FOR MOBILE DEVICES v0.01.
Tracking & Login Data persistence User tracking.
CS 333 Introduction to Operating Systems Class 11 – Virtual Memory (1)
Slides prepared by Rose Williams, Binghamton University Chapter 5 Defining Classes II.
© 2009 Research In Motion Limited Data structures and memory management on mobile devices.
Hash Tables1 Part E Hash Tables  
V0.01 © 2009 Research In Motion Limited Introduction to Java Application Development for the BlackBerry Smartphone Trainer name Date.
1  Caches load multiple bytes per block to take advantage of spatial locality  If cache block size = 2 n bytes, conceptually split memory into 2 n -byte.
Cosc 4730 Phone Programming in Java An Introduction.
Portable Software. This program will explain what portable software is, how it can be used, and where it can be found. This is an advanced level technology.
Passage Three Storage Devices. Training target: In this part , you should try your best to form good reading habits. In order to avoid your ill habits.
This is the first page of the log in, this is were you enter your unique details.
Proxy Design Pattern Source: Design Patterns – Elements of Reusable Object- Oriented Software; Gamma, et. al.
File System. NET+OS 6 File System Architecture Design Goals File System Layer Design Storage Services Layer Design RAM Services Layer Design Flash Services.
Password Management Programs By SIR Phil Goff, Branch 116 Area 2 Computers and Technology April 18,
PROG Mobile Java Application Development PROG Mobile Java Application Development Event Handling Creating Menus.
 FILE S SYSTEM  DIFFERENT FILE SYSTEMS  FILE SYSTEM COMPONENTS  FILE OPERATIONS  LOG STRUCTERD FILE SYSTEM  FILE EXAMPLES.
Databases for Mobile Devices Introduction. Overview Different types of data storages Memory management Local database techniques.
Computers in the real world Objectives Understand what is meant by memory Difference between RAM and ROM Look at how memory affects the performance of.
CSC 213 – Large Scale Programming. Today’s Goal  Consider what will be important when searching  Why search in first place? What is its purpose?  What.
Move Pictures From Your Mobile Phone to Your PC.  You never know when a photo opportunity is going to arise, which is why having a camera phone can be.
CS378 - Mobile Computing Persistence. Saving State We have already seen saving app state into a Bundle on orientation changes or when an app is killed.
PHP meets MySQL.
What is Digital Photography? Lesson One Mrs. Johnson Winter/Spring 2012 Digital Photography Course.
Activities and Intents. Activities Activity is a window that contains the user interface of your application,typically an application has one or more.
PROG Mobile Java Application Development PROG Mobile Java Application Development BlackBerry App Lifecycle Java ME API.
Installation Overview Lab#2 1Hanin Abdulrahman. Installing Ubuntu Linux is the process of copying operating system files from a CD, DVD, or USB flash.
Chapter 3.5 Memory and I/O Systems. 2 Memory Management Memory problems are one of the leading causes of bugs in programs (60-80%) MUCH worse in languages.
Nilesh Singh Local Data Storage option Android provides several options for you to save persistent application data. - Shared preferences - Creation.
Operating Systems COMP 4850/CISG 5550 File Systems Files Dr. James Money.
Persistent Storage using Perst Lite in Android. Introduction  Android by default uses SQLLite to handle data storage  SQLLite is a relational database.
Buffers Let’s go for a swim. Buffers A buffer is simply a collection of bytes A buffer is simply a collection of bytes – a char[] if you will. Any information.
BlackBerry Persistent Storage Models Persistent Storage APIs and Record Management System.
Linked List. Background Arrays has certain disadvantages as data storage structures. ▫In an unordered array, searching is slow ▫In an ordered array, insertion.
Views Lesson 7.
STATE MANAGEMENT.  Web Applications are based on stateless HTTP protocol which does not retain any information about user requests  The concept of state.
1 File Systems: Consistency Issues. 2 File Systems: Consistency Issues File systems maintains many data structures  Free list/bit vector  Directories.
1 C++ Classes and Data Structures Jeffrey S. Childs Chapter 4 Pointers and Dynamic Arrays Jeffrey S. Childs Clarion University of PA © 2008, Prentice Hall.
Can’t provide fast insertion/removal and fast lookup at the same time Vectors, Linked Lists, Stack, Queues, Deques 4 Data Structures - CSCI 102 Copyright.
Computer security By Isabelle Cooper.
CS378 - Mobile Computing Persistence. Saving State We have already seen saving app state into a Bundle on orientation changes or when an app is killed.
Discovering Computers Fundamentals, 2010 Edition Living in a Digital World Chapter Five SOFTWARE.
Fall 2002CS 150: Intro. to Computing1 Streams and File I/O (That is, Input/Output) OR How you read data from files and write data to files.
Garbage Collection and Classloading Java Garbage Collectors  Eden Space  Surviver Space  Tenured Gen  Perm Gen  Garbage Collection Notes Classloading.
File Systems cs550 Operating Systems David Monismith.
PROG Mobile Java Application Development PROG Mobile Java Application Development Data Storage, Continued.
CMSC 202 Advanced Section Classes and Objects: Object Creation and Constructors.
11.1 Silberschatz, Galvin and Gagne ©2005 Operating System Principles 11.5 Free-Space Management Bit vector (n blocks) … 012n-1 bit[i] =  1  block[i]
CSCI 156: Lab 11 Paging. Our Simple Architecture Logical memory space for a process consists of 16 pages of 4k bytes each. Your program thinks it has.
© 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. Android Boot Camp.
Chapter 11 Analysis Methodology Spring Incident Response & Computer Forensics.
CHAPTER 9 File Storage Shared Preferences SQLite.
How to Recover Deleted Contacts from Samsung Phone How many phone numbers do you save on your contact list? As a matter of fact, as you use mobile phones.
Mobile Application Development Data Storage. Android provides several options for you to save persistent application data. The solution you choose depends.
Data Storage in Android Димитър Н. Димитров. Why talk about data? Why not 3D graphics or network connectivity? Data as fundamental term in computer science.
Advance Computer Programming Market for Java ME The Java ME Platform – Java 2 Micro Edition (J2ME) combines a resource- constrained JVM and a set of Java.
1 Terminal Management System Usage Overview Document Version 1.1.
Dial-In Number: 1 (631) Webinar ID: FHC Tech Talk Automation and Efficiency Series Talk #1 Carbonite automated backup.
Android Application Data Storage 1.
Chapter 2 Memory and process management
Print Out Text Messages from Android Phone Mac/Win
Data Storage In today’s lesson we will look at:
Cloud Storage Services
Testing & Security Dr. X.
Presentation transcript:

PROG Mobile Java Application Development PROG Mobile Java Application Development Memory and Memory Issues Data Storage

10/17/2015Wendi Jollymore, ACES2 Types of BB Memory Internal Flash Memory aka application storage, onboard memory internal to the device contains the operating system and BB JVM (about 10MB to 15MB) only place where apps can be run available on all bb devices stores messages, organizer data, personal information, etc where persistent objects/data is stored older devices around 32MB or more storm is 128MB, storm 2 is 256MB, torch is 512MB

10/17/2015Wendi Jollymore, ACES3 Types of BB Memory SRAM ml Static RAM Working memory E.g. when a persistent object is accessed/edited it is copied to SRAM and worked on there Controls transient data objects data objects that have been created during an app session and not saved anywhere Controls runtime processes BlackBerry stopped posting amount of SRAM on devices :P

10/17/2015Wendi Jollymore, ACES4 Types of BB Memory External SD (Secure Digital) cards microSD card that can be inserted to extend storage on device optional, removable, contains a FAT file system supported on o/s 4.2 or later, except 8700 series amount of SD card storage varies the device can support up to a certain amount (see specs for each device) users might only have a certain sized card E.g. Storm, Storm2, Torch all support up to 32GB card, but some carriers include 8GB card with device

10/17/2015Wendi Jollymore, ACES5 Types of BB Memory Built-in media storage (device memory) embedded multimedia card (eMMC) not removable also known as internal memory or onboard device memory not on all devices, and size varies on those that have it E.g. Storm has 1GB, Storm 2 has 2GB, Torch has 4GB

10/17/2015Wendi Jollymore, ACES6 Persistence & Object Handles Persistent storage – storage that persists when app is not running and device shut off Data that isn’t deleted when app stops or device resets/shuts down The opposite is non-persistent storage Data that is still there as long as the device is running But is lost when the device shuts off/resets

10/17/2015Wendi Jollymore, ACES7 Persistence & Object Handles Two kinds of object handles: Object Handles (Transitive Object Handles) Every object you use requires a “handle” in memory Think of it sort of like a reference to that object Persistent Object Handles For objects that are persisted across device resets i.e. stored persistently on the device

10/17/2015Wendi Jollymore, ACES8 Persistence & Object Handles Example: A vector of 10 strings will consume 11 persistent object handles 1 handle for the vector 10 handles for each string in the vector There is a fixed number of persistent object handles available in the system Determined by the amount of flash memory. A 32MB device is limited to about 65,000 persistent object handles and 132,000 object handles. You could run out of persistent object handles well before you run out of memory

10/17/2015Wendi Jollymore, ACES9 Low Memory Manager If SRAM runs low, JVM swaps with flash memory If flash memory is full, problems! Garbage collector tries to free up memory no longer in use When SRAM and flash memory get full Garbage Collector runs more often and it will take longer

10/17/2015Wendi Jollymore, ACES10 Low Memory Manager Handles memory resources on the BB when available When resources fall below a certain thresh-hold Frees used memory to provide more available memory All apps work with the low memory manager to free as much memory as possible when device is low on memory When low memory manager will work: Amount of flash memory falls below a certain threshhold (usually 400KB to 800KB) # of persistent object handles available falls below 1000 # of object handles available falls below 1000

10/17/2015Wendi Jollymore, ACES11 Low Memory Manager Will remove low priority stuff like cached data Then will go to medium priority stuff old s and out of date calendar entries If critical, will remove more recent s, phone logs, etc

10/17/2015Wendi Jollymore, ACES12 Conserve Memory Resources Flash memory Refers to the raw persistent storage space that is available on each handheld. Remember that this is fixed Amount depends on device This is where persistent data and object handles are stored

10/17/2015Wendi Jollymore, ACES13 Conserve Memory Resources Reduce the number of objects! Fewer objects means fewer persistent object handles and object handles Recall Vector example with 10 String objects 11 handles If you had 3000 records, that’s 33,000 handles On some older devices with only 16MB memory, this is too much A device with 16MB flash memory can only hold 27,000 persistent object handles

10/17/2015Wendi Jollymore, ACES14 Conserve Memory Resources Data Structure Selection Make sure data structure contains minimum possible number of objects especially with vector or hashtable - great objects but resource heavy - avoid using if possible Use primitive types instead of objects - primitives require no object handle Note that an array is an object so an array of primitives requires one object handle Strings are equivalent to byte arrays so a string will take one object handle

10/17/2015Wendi Jollymore, ACES15 Conserve Memory Resources Object consolidation Recall Vector example with 10 String objects and 3000 records net.rim.device.api.system.ObjectGroup allows you to group objects so that they take only one handle string example that takes 11 - can group this into 1) Problem: grouped objects are read only so if you edit, you must ungroup, change, re-group again – can affect performance also ungrouping it obviously requires all the object handles again

10/17/2015Wendi Jollymore, ACES16 Minimize Memory Usage Use primitive data types instead of objects E.g. use int instead of Integer Do not depend entirely on the garbage collector. Avoid creating many objects quickly. Set object references to null when you are finished using them. Reuse objects as much as possible. Move heavy processing to the server. Example: filter or sort data before sending it to the BlackBerry smartphone.

10/17/2015Wendi Jollymore, ACES17 Storage Choices MIDP RMS (record mgmt system) simple non-relational database format stores data in arrays of bytes not much support for sharing data between apps app data is attached to app, so when app is removed from device, so is data use this if you're developing for older devices or developing a MIDlet javax.microedition.rms package

10/17/2015Wendi Jollymore, ACES18 Storage Choices BlackBerry Persistent Store similar to RMS easier to store wider range of objects can store instances of custom classes offers optional compression and security most popular can be written only to the devices internal flash memory persists across device resets

10/17/2015Wendi Jollymore, ACES19 Storage Choices runtime store similar to persistent store doesn't persist across device resets used for apps to share info

10/17/2015Wendi Jollymore, ACES20 Storage Choices FileConnection API Allows access to BlackBerry file system files and folders Can access application storage, SD card, device memory File system is where media, pics, downloaded files, attachments from s, etc are stored Accessible by all apps on the device Good for large files, pics, documents Good for files that need to be accessible (e.g. thru desktop manager)

10/17/2015Wendi Jollymore, ACES21 Storage Choices SQLite (5.0 and later) Full database for structured data Can store and access data on device's internal memory and external sd cards

10/17/2015Wendi Jollymore, ACES22 BB Persistent Store Stores data to flash memory Can't access SD card not good for documents or anything large Flash memory contains the O/S, , other data still should be a lot free – check device specs

10/17/2015Wendi Jollymore, ACES23 BB Persistent Store net.rim.device.api.system.PersistentStore Manages a list of keys (long) and objects (PersistentObjects) List is global across all apps You don't know which keys are in use by other apps However, key space is large enough that conflicts never occur Think of key like the ID or file name

10/17/2015Wendi Jollymore, ACES24 BB Persistent Store net.rim.device.aip.system.PersistentObject PersistentStore.getPersistentObject() returns an instance of PersistentObject even if key hasn't been used before therefore, you will always get back a PO, but it might have a null value so either nothing has been saved with that key or it was deleted

10/17/2015Wendi Jollymore, ACES25 BB Persistent Store PersistentObject persistentObject = PersistentStore.getPersistentObject(0x2a5c 4229e L); Contents of the Persistent Object are accessed via the getContents() method, which might return null: Object contents = persistentObject.getContents(); To set or replace the contents of a PO, use setContents() method: Hashtable hashtable = new Hashtable(); persistentObject.setContents(hashtable);

10/17/2015Wendi Jollymore, ACES26 BB Persistent Store Setting contents doesn't necessarily mean object has persisted must call commit() method: persistObj.commit(); Persistent Object maintains a reference to its contents to change the data in the persistent object, you must modify the instance and call commit() you don't need to call setContents() again unless you want entirely different object to be associated with that key

10/17/2015Wendi Jollymore, ACES27 BB Persistent Store // This will persist MyKey and New Value // no need to call // persistentObject.setContents() again hashtable.put("MyKey", "New Value"); persistentObject.commit();

10/17/2015Wendi Jollymore, ACES28 What Can You Persist? Only objects, not primitives (use wrapper classes) Any object you persist must implement net.rim.device.api.util.Persistable interface Some other classes are allowed even though they don't implement Persistable: wrapper classses, Object, String, Vector, Hashtable Arrays of primitives and other persistable types

10/17/2015Wendi Jollymore, ACES29 What Can You Persist? Persistence saves entire object including all objects it references Objects your object references must also be persistable e.g You want to persist a Hashtable of Employee objects Employee class must be persistable (implement Persistable interface)

10/17/2015Wendi Jollymore, ACES30 Exercises Do the example in Beginning Blackberry (Persistent Store section) Do the tutorials and lab from the RIM materials There is also a lab using Runtime store from the RIM materals All of this is in the notes