No matter how much an application is given, it could always ask for more.
There are two big differences between an Android device, like a phone or tablet, and a traditional computer:
Typically, today's computers come installed with several gigabytes of RAM (few come installed with only 1GB or less), however Android devices often have a maximum of 512MB of RAM. To add insult to injury, computers use swapping, which Android devices don't have, to give the system and applications the illusion of more memory. For example, an application could still address up to 4GB of memory even with a system that has only 256MB of RAM. Your Android application simply does not have this luxury, and therefore you have to be more careful about how much memory your application uses.
NOTE: You can find applications on Android Market that enable swapping, but they require root access and a different Linux kernel. Assume the Android devices your applications will be running on do not have swapping capabilities.
The Java language defines the size of most primitive types, as shown in Table 4-1, together with their matching native types. If you are primarily familiar with C/C++ code, then you need to pay extra attention to two things:
A good rule of thumb is to use as little memory as possible, which is just common sense as your Android device and applications have a limited amount of memory. But in addition to reducing the risk of an OutOfMemoryError
exception, using less memory can also increase performance.
Performance depends mostly on three things:
We will cover each one of these items, looking at both native code and Java code, measuring execution times, and comparing several implementations of simple algorithms to improve performance.
18.191.235.62