No matter how careful it is, it is impossible to avoid bad code altogether, and tools are needed to help us check if there is a memory leak in the code. The DDMS in Android tools comes with a very good memory monitoring tool heap (here I use the Eclipse ADT Plugin, and in the case of a real machine, like in the emulator). The steps to use the heap to monitor the
Android memory and performance optimization Summary
1. Instant Compilation (Just-in-time Compilation, JIT), also known as Dynamic Translation (Dynamic Translation), is a way to translate bytecode into machine code at runtime, this improves the performance of bytecode compiling languages. The two runtime theories at the early stage of real-time compilation are bytecode compilation and dynamic compilation.
. When memory is low, it needs to be maintained, and the process with the service has a higher priority.1. If the service is calling the Oncreate,onstartcommand or Ondestory method, then the process used for the current service becomes the foreground process to avoid being killed.2. If the current service has been started (start), the process that owns it has a lower priority than those visible to the user, but is more important than the invisible pro
service has been started (start) or the client is connected (Bindservice) to it. When memory is low, it needs to be maintained, and the process with the service has a higher priority.1. If the service is calling the Oncreate,onstartcommand or Ondestory method, then the process used for the current service becomes the foreground process to avoid being killed.2. If the current service has been started (start), the process that owns it has a lower prior
system can allocate for the app, andtotalmemory () Gets the amount of memory heap space currently allocated by the app. I have two mobile phones, a oppo Find7, running the color OS, measured maximum memory allocation of 192MB; a day language v9, running millet system, measured maximum
total size value of the data object; B) NBSP; normal total Size value will stabilize within a limited range , That is, because the code in the program is good, there is no case that the object is not garbage collected, so we say although our continuous operation will generate many objects constantly, and in the virtual machine constantly GC , the objects are recycled , and the memory footprint falls to a stable level; c) Conversely, if there
Size value will be stable in a limited range under normal circumstances , that is, because the code in the program is good, there is no object is not garbage collection, so that although our continuous operation will continue to generate many objects, And in the process of the virtual machine continuous GC , these objects are recycled , memory consumption will fall to a stable level;c) Conversely, if there is a case in the code that does not release
The performance test simulates various normal, peak, and abnormal load conditions through automated test tools to test the system's performance indicators. And the performance of the app is getting more and more attention, let's introduce the performance test method of the app. However, the performance test is a reference value, and no matter what test method is impossible to accurately test the actual perf
, which prevents the installation from being overwritten when it is installed again. Solution: Apply a full uninstall (after the device is connected to the computer, in debug mode via the command line: ADB uninstall
(special) Phone native system error, which causes some applications to be installed. Solution: Restore the factory settings, if necessary, double wipe (Shuangqing) to brush the machine;
Installation package resolution failed:
APK file is corrupted;
statistics" to Google's inquiry box, select and click "Proceed"3. In the main configuration panel, modify "SDK location" as the SDK path "D:\ANDROID-SDK" in step two. Click "Apply" > "OK" step four. Add platform version and Component SDK main body is divided into Android platform versions, add-ons, tools, samples,and documentation and other parts. The SDK downloaded in step two is just the latest SDK tools
. Java file, calculate the oom_adj of the process, for example:[Java] View plaincopyprint?
If (APP = top_app ){
// The Last app on the list is the foreground app.
Adj = foreground_app_adj;
App. adjtype = "Top-activity ";
}
if (app == TOP_APP) { // The
Android 4.4 power-saving technology details: How to Develop a power-saving app, android4.4
With the launch of Android 4.4, Google said it had improved its power-saving technology! Let's take a look at the changes in the power-saving technology of Android 4.4!
Test conclusion:
1) screen-off standby power-saving:
A) Any
. Memory size consumption varies depending on the device, operating system level, and screen size
3. The program cannot be directly controlled
4. Support for background multi-task processing (multitasking)
5. Run on a virtual machine
5R:
This article mainly uses the following 5R method to optimize the ANDROID memory:
1. Reckon (Computing)
First, you need to kno
uncompressed image and the Android bitmap occupy a lot of memory, which causes the Java garbage collector to run more frequently and makes the application more slow, especially on Android 5.0, which does not have a perfect garbage collector.In Android 4.x and below, fresco places pictures in a special location on
how the Android app worksAndroid is based on the Liunx kernel, but unlike traditional liunx-based PC systems,The user has no absolute control over the Android app. PC System,selecting "Exit" or "close" option on the application's system menu will kill the process directly. This is not the case with
single process. Android apps have a standalone virtual machine, which opens a separate virtual machine for each application (so the design will not crash the entire system in the event of a single program crash).Note: When Heapgrowthlimit is set, a single process can have a maximum memory value of Heapgrowthlimit. In Android development, if you want to use a lar
totalMemory () to obtain the heap space allocated by the APP. I have two mobile phones in my hand, one Oppo find7 and a Color OS. The maximum memory size is 192 MB. The other is Tianyu v9 and the maximum memory size is 100 MB when I run the Xiaomi system. As Android is an open-source system, different mobile phone man
, it takes 162 ms to complete the entire call! This is a problem!
The author continues to view the submethods of getView () and shows the ratio of the time used by each submethod to the total time. He found that the random Real Time of Thread. join () takes about 98%. He finds the Thread of the promoter method. run () method (it is the method called when a new thread is created), followed one by one until the "culprit" is found: BgService. doWork () method.
In addition, GC (Garbage Collector-Gar
file is private data and can only be accessed by the app itself, in which the content of the write overwrites the contents of the original file, if you want to append the newly written content to the original file. You can use Context.mode_appendContext.mode_append: The mode checks whether the file exists, appends content to the file, or creates a new file.Context.mode_world_readable and context.mode_world_writeable are used to control whether other
ridiculously low. for a device, like the Nexus One, with 512 MB of physical Ram, setting the per-process memory limit for the foreground activity to only 5% of the Ram is a silly mistake. but anyway, that's how things are and we have to liveIt-I. e. find how to work around it.
There are two ways to allocate much more memory than the limit:
One way is to allocate memory
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.