Acceleration for your App-Android optimizer guide

Source: Internet
Author: User

Text link: Speed up your app original author: UDI COHEN translation from: Development technology front www.devtf.cn. Without permission, not reproduced! Translator: Zijianwang90 Reviewer: status: complete

A few weeks ago, I had a speech on Android performance optimization on Droidcon NYC.

I spent a lot of time in this speech because I wanted to show real-life examples of performance issues and what tools I was using to discover them. Because of time, I had to abandon half of the content in the speech. In this article, I'll summarize everything I've discussed in my speech, and give examples

Click this link to enter the presentation video

Now, let's talk about some of the key points I mentioned in my speech, and I hope my elaboration is clear enough. First of all, I followed the following guidelines when I was optimizing my performance:

Principle

Whenever I encounter performance problems, or try to discover performance issues, I follow the following guidelines:

    • Stick to performance testing-don't use your eyes to optimize performance. Maybe after you look at the same animation a few times, you will start to believe that he is running more and more smoothly. Data does not lie. Before and after you optimize your code, use the series of tools we'll be introducing to test your app's performance geometry many times.
    • Use low-end devices-low-end devices tend to be easier if you want to expose your application's performance problems. Powerful devices tend not to care too much about your application of some of the optimization issues, and not all users are using these flagship devices.
    • Tradeoff-performance optimization always revolves around the tradeoff between the two words. Your optimizations at one point may cause problems on the other. In many cases, you will spend a lot of time looking for and solving these problems, but the cause of these problems can also be caused by, for example, the quality of bitmaps, or you do not use the right data structure to store your data. So you have to be ready to make some sacrifices.
Systrace

Systrace is a great, but potentially overlooked, tool because developers are often unsure what information systrace can offer them.

Systrace will show an overview of the status of the program running on the phone. This tool reminds us that the phone is actually a computer that can do a lot of work at the same time. In a recent SDK update, this tool has been improved in data analysis capabilities to help us find performance issues.

Let's look at what Systrace looks like:

You can generate the Systrace file from the Android Device Monitor tool or the command line to learn more about the poke here.

In the video, I introduce the functions of different areas in Systrace. Of course the most interesting is the alerts and frames two columns, which show the visual analysis results generated by the data from the phone. Let's choose the top alerts to see:

This warning indicates that there is a View#draw () method that executes for a relatively long time. We can see the description of the problem, links, and even related videos below. Let's look at the frames line below, and we can see that each frame that is drawn is shown here, and the green, yellow, and red three colors are used to distinguish the performance of the drawing. Let's choose a red frame to look at:

At the bottom, we see some caveats related to this frame. Of these three warnings, one is what we mentioned above (View#draw ()). Next we zoom in at this frame and expand the "inflation during ListView recycling" warning below:

We can see the total time spent on the warning part, 32 milliseconds, much higher than the 16 millisecond draw time we need to protect 60fps. There are also more ListView each entry's drawing time, about 6 milliseconds per entry, a total of five. The content in the description description will help us understand the problem and even provide a solution to the problem. Back to our last picture, we can zoom in on the block area of "inflate" and see exactly which view is more time-consuming during the filling process.

Here's another example of a slow rendering:

After selecting a frame, we can press the "M" key to highlight the frame, and at the top we see this part of the time-consuming, we see that this burst of drawing takes more than 19 milliseconds. And when we unfolded the only warning of this frame, we found the error "scheduling delay".

Scheduling delay (dispatch delay) means that a thread has not been assigned to the CPU for a long period of time when it is processing a block of operations, causing the thread to not complete its work for a long time. We select the longest piece in this frame to get more detailed information:

In the red-framed area, we see "Wall duration", which represents the time-consuming period of the start-to-end of this chunk. It is called "Wall duration" because he is like a clock on the wall, timing you from the beginning of the thread.

However, CPU duration shows the time that the actual CPU consumes in processing this chunk.

Obviously, the gap between the two times is still very large. The entire chunk takes 18 milliseconds, while the CPU consumes only 4 milliseconds to operate. This is a bit strange, so we should look at what the CPU is doing in this whole process.

As you can see, all four threads are very busy.

Choosing one of these threads will tell us which program is taking him, and here is a package named Com.udinic.keepbusyapp program. Here, because another program consumes the CPU, our program fails to get enough CPU resources.

However, this is a temporary situation, because the CPU is not seen by other background applications (--), but there are still other application threads or the main thread that consumes the CPU. And TraceView can only provide us with an overview, his depth is limited. So to find out what's really going on in our app to get our CPU busy, we need another tool to--traceview.

Traceview

TraceView is a performance testing tool that shows the elapsed time of all methods. Let's look at what he looks like:

This tool can be opened from Android Device Monitor or by code. Read more about the news here.

Let's take a look at the meaning of each column:

    • Name-the method name, and the color they correspond to in the chart above.
    • Inclusive CPU time-cpu The total time taken to process this method and all the sub-methods, such as all methods that he invokes.
    • Exclusive CPU time-cpu is always time consuming to process this single method.
    • Inclusive/exlusive Real time-from the beginning of the method to the end of execution, and similar to the "Wall duration" in Systrace
    • Calls+recursion-the number of times this method was called, and the number of times the call was recursive.
    • Cpu/real time per call-the average CPU time spent processing this method and the actual time-consuming average. The additional column shows the cumulative time-consuming of all calls to this method

I opened an application that slipped less smoothly. Turn on the record, swipe a bit and stop recording. Expand the GetView () method, such as:

This method is called 12 times, each time the CPU consumes about 3 milliseconds, but the total time spent on each call is as high as 162 milliseconds! Definitely a problem!

And looking at the children of this approach, we can see how each of these methods is distributed over time. The Thread.Join () method is a 98% inclusive real time. This method is called when waiting for the other thread to end. Another method in children is the Tread.start () method, and the whole method takes a long time, I guess because the thread is started in the GetView () method and is waiting for it to end.

But where is this thread?

We do not see what this thread does in the GetView () method, because this logic is not in the GetView () method. So I found the Thread.run () method, which is the method that runs when the thread is created. And following this method all the way down, I found the culprit of the problem.

I found that each invocation of the Bgservice.dowork () method took nearly 14 milliseconds, and there were 40 of these things! And it is possible to call this method multiple times in GetView (), which explains why the GetView () method executes so long. This method keeps the CPU in a busy state for a long time. And looking at exclusive CPU time, we can see that he occupies 80% of the CPU! In addition, depending on the exclusive CPU time sequencing, you can help us to better locate those long-consuming methods that are likely to be the culprit for performance problems.

Focusing on these time-consuming methods, such as GetView (), View#ondraw (), can be a good way to help us find out why the application is running slowly. But sometimes there are other things that can take up valuable CPU resources that, if applied to the drawing of the UI, may be more streamlined. The garbage collector garbage collection mechanism will run periodically, reclaiming useless objects, which generally do not affect the programs we run in the foreground. But if the GC is running too often, he can also affect the execution efficiency of our application. And how do we know if recycling is too frequent ...

Memory Tuning Memories Profiling

Android Studio has given us more powerful tools to analyze performance issues in recent updates. The Memory tab in the bottom Android option shows how much data was allocated to the heap memory, and he grew up like this:

And when a small slide in the chart shows that GC recycling has occurred, he cleans up unnecessary objects and frees up some heap space. On the left side of this chart there are two tools for us to use, Head dump and allocation Tracker.

Heap Dump

To find out exactly what is taking up our heap memory, we can use the heap dump button on the left. He will provide a snapshot of the heap's memory footprint and will open a separate reporting interface in Android Studio.

On the left, we see an icon that shows all the instances in the heap, grouped by class. For each instance, it shows how many instances of the object are allocated to the heap, and the space they occupy (shallow size), and the space that these objects still occupy in memory, which tells us how much of the memory space will be freed if those instances are freed. This tool allows us to visually observe how memory is being used, to help us analyze the relationship between the data structures and objects we use, to identify problems and to use more efficient data structures, to unlock and correlate with objects, and to reduce the ratained memory footprint. And the ultimate goal is to reduce our memory footprint as much as possible.

Looking back at the chart, we found that there are 39 instances of memoryactivity, which is a bit odd for an activity. Select one of these instances on the right, and you will see a list of all references to this instance below.

One of these is a collection of Listenersmanager objects. and observing the other instances of the activity, they are all kept in memory because of this object. This also explains why these objects occupy so much memory:

This phenomenon is called "memory leaks", our activity has been destroyed, but their objects are always referenced and cannot be garbage collected. We can avoid this situation, for example, to ensure that these objects are not being referenced by other objects until they are destroyed. In our example, Listernesmanager does not need to keep a reference to these objects after the activity has been destroyed. So the solution is to remove these references in the OnDestroy () callback method.

Memory leaks and other large objects occupy a large number of controls in the heap, reducing the amount of available memory while also causing frequent garbage collection. While garbage collection is causing the CPU to be busy, and heap memory does not become larger, it will eventually result in more tragic results: outofmemoryexception memory overflow and cause the program to crash.

Another more advanced tool is the Eclipse Memory Analyzer tool (Eclipse MAT):

This tool can do all that Android studio can do, identify possible memory leaks, and provide more advanced search capabilities, such as searching for all bitmap instances larger than 2MB, or searching for all empty rect objects.

Another good tool is leakcanary, a third-party library that can observe objects in your application and make sure that they do not cause leaks. And if there is a leak, there will be a push to remind you where something has happened.

Allocation Tracker

We can find the start and stop buttons of the allocation tracker on the left side of the memory graph. He generates a report of all instances that have been generated within a certain amount of time and is grouped by class classification:

or grouped by method:

It can also tell us which methods or classes have the most instances through an aesthetically pleasing visual interface.

With this information, we can find methods that consume too much memory, cause multiple garbage collections, and are time-sensitive. We can also use this tool to find a lot of short-lived instances of the same class, so we can consider using the idea of object pooling to minimize the creation of too many instances.

Common Memory Tips

Here are some of the rules or tricks I follow when I write code:

  • enumeration has always been a topic of constant discussion on performance issues. Here is a video that discusses enumerations, pointing out the memory space consumed by enumerations, and there is a discussion about this video, and there are, of course, some misleading ones. But is the enumeration really more space-intensive than the usual constants? Yes, sure. But it must be bad? Not necessarily. If you are writing a library and require strong type security, you might be able to use enumerations instead of other methods, such as @intdef. And if you just have a bunch of constants, using enumerations might not be wise. Or that sentence, before you make a decision must weigh and trade-offs.
  • Auto Boxing-Auto Boxing is a boxing process from the raw data type to the object type data (for example, int to integer). Whenever a raw type of data is boxed into an object type data, a new object is created (shocked.) )。 So if there are many times of automatic boxing, it is bound to speed up the frequency of GC execution, and automatic boxing is very easy for us to ignore. The solution, when using these types, is as consistent as possible, if you use the original data type completely in the application, then try to avoid him being automatically encapsulated for no reason. You can use the Memery profiling tool we mentioned above to find these too many object type data, or you can traceview to find similar integer.valueof (), long.valueof () Such a way to determine whether a large number of unnecessary automatic encapsulation occurred.
  • HashMap vs Arraymap/sparse*array -Since the question of automatic boxing is mentioned, then using HASHMAP, we need to use the object type as the key. And if we are using the "int" of the basic data type throughout the application, then we will have automatic boxing when we use HashMap, and perhaps we can consider using Sparseintarray. And if we still need the key as the object type, then we can use Arraymap. Arraymap and HashMap are similar, but at the bottom of the implementation principle is not the same, this will let us more efficient use of memory, but pay a certain performance cost. Both methods will save more memory space than HashMap, but there will be some sacrifices compared to HashMap, the speed of query and deletion. Of course, unless you have at least 1000 data sources, it's not going to have too much impact on speed at run time, which is one of the reasons you use them instead of hashmap.
  • Note the context -as we have seen before, activity is very easy to cause memory leaks. In Android, the most likely cause of memory leaks is activity. And these memory leaks can waste a lot of memory because they hold all of the view in their UI, and these view usually occupy a lot of controls. Many operations in the development process require context, and I usually use activity to pass it on. So be sure to figure out what you've done with this activity. If a reference is cached and the object's lifetime is longer than your activity, then the memory leak will occur before we release the reference.
  • avoid non-static -when we create a non-static inner class and initialize it, an implicit reference to the outer class is created inside it. If the life cycle of the inner class is longer than the outer class, then the outer class is also kept in memory, even though we do not need it at all. For example, within the activity, you create an inner class that inherits from Asynctask, and then starts the async task when the activity is running, and then kills the activty. Then this async task will hold the activity until the end of execution. And the solution is very simple, do not do so, try to use static internal classes.
Monitor GPU (GPU Profiling)

A new tool in Android 1.4 is the ability to view GPU drawing.

Each line means that one frame is drawn, and the different colors in each line represent different stages in the drawing process:

    • Draw (blue) represents the View#ondraw () method. In this session, objects in the displaylist are created/refreshed, which are later converted to OpenGL commands that the GPU can understand. The higher the value may be because the view is more complex and requires more time to create their display list, or because too many view is created in a short period of time.
    • Prepare (purple) -in the lollipop version, a new thread is added to the UI thread to help draw the UI. This thread is called Renderthread. It is responsible for converting the display list to the OpenGL command and sending it to the GPU. In this process, the UI thread can continue to start processing the subsequent frames. The time consumed by the purple phase is when the UI thread passes all the resources to the renderthread process. If there is a lot of resources to pass through in this process, the display list becomes too heavy to take too long in this phase.
    • Process (red) -executes the contents of the display list and creates the OpenGL command. If there is too much or too complex a display list to execute, then this phase will take a long time, because there will be a lot of view being redrawn. Repainting often occurs when the interface is refreshed or moved out of the covered area.
    • Execute (yellow) -sends the OpenGL command to the GPU. This phase is a blocking call because the CPU only sends a buffer that contains some OpenGL commands to the GPU, and waits for the GPU to return an empty buffer to pass the next frame's OpenGL command again. The total amount of these buffers is certain, if the GPU is too busy, then the CPU will wait for the next empty buffer. So, if we see this phase taking a long time, it could be because the GPU is too busy drawing the UI, and the reason for this might be to draw overly complex view in a short period of time.

In the marshmallow version, more colors were added, such as the measure/layout phase, input handling, and some others:

Before using these features, you need to turn on GPU rendering (GPU rendering mode analysis) in the developer options:

Next we can get all the information we want by following this adb command:

adb shell dumpsys gfxinfo <PACKAGE_NAME>

We can collect this information ourselves and create charts. This command also prints out some other useful information, such as the number of layers in the view hierarchy, the size of the display lists, and so on. In Marshmallow, we will also get more information:

If we need to test our app automatically, we can create our own server to run the commands on a specific node (such as list scrolling, heavy animation, etc.) and observe the changes in these values. This can help us find out where the performance is falling and where the product is going to go before it goes live. We can also find more accurate data through the "framestats" keyword, which is explained in more detail here.

But that's not the only way to get GPU rendering data!

After we have seen the "Profile GPU Rendering" option in the GPU rendering mode analysis in the developer options, there is another option, "on screen as Bars" (shown as a bar chart). With this open, we can visually see how long each frame consumes during the drawing process, while the green horizontal line represents the 16ms 60fps 0 boundary value.

In the example on the right, we can see that a lot of frames are out of the green Line, which means it takes 16 milliseconds more time to draw. While blue occupies the body of these lines, we know that this may be because too much or too complex a view is being drawn. In this case, when I swipe the list, because the structure of the view in the list is more complex, some of the view has been drawn and some are in the drawing phase because they are too complex, which is probably why these frames are more than the green line-it's too complicated to draw.

Hierarchy Viewer

I like this tool very much, at the same time because so many people do not have to feel a trace of sadness.

Using the hierarchy Viewer, we can get performance data, observe each view in the view hierarchy, and see the properties of all view. We can also export theme data so that we can see the value of the property in each style, but we can only do this when we run the hierarchy viewer alone, not through Android Monitor. I usually use this tool when I do layout design and layout optimization.

In the middle, the tree structure we see represents the level of view. The view hierarchy can be wide, but if it is too wide (about 10 layers), it may consume a lot of performance in the layout and measurement phases. Each time the view is measured by the View#onmeasure () method, or when all of his child views are laid out through the View#onlayout () method, the methods are passed back to all of its child views and start over. Some layouts will do the above steps two times, such as Relativelayout and some of the configured LinearLayout, and if they are nested again, then the delivery of these methods will increase a lot.

At the bottom right, we see a "blueprint" of our layout, where each view is labeled. When we click here (or from the tree structure), we will see all of his attributes on the left. When designing layouts, sometimes I'm not sure why a view is being placed there, and using this tool, I can find this view in the tree view, select it, and see where he is in the preview window. I also design interesting animations by looking at the final drawing size on the screen, and use this information to make the animation or view position more precise. I can also use this tool to find the view that is not found by other view accidentally, and so on.

For each view we can obtain his measurement, layout, and drawing with all the child view that it contains. Here the color represents this view during the drawing process, compared to the performance of other view in the tree, which is the best way to find these poor performance view. Since we can see the preview of all the view, we are able to follow the tree view in the order in which it was created, looking for the extra steps that can be discarded. One of them, too, has a great impact on performance, which is over-drawing.

Over-Drawing

As we saw in the GPU profiling section, in the Execute yellow phase, if the GPU has too much to draw on the screen, the entire stage consumes more time, and colleagues increase the time that each frame consumes. Over-drawing often happens when we need to draw something else on one thing, such as a yellow button on a red background. Then the GPU will need to draw a red background, and then draw a yellow button on top of him, when the excessive drawing is inevitable. If we have too many layers to draw, then excessive GPU usage will cause us to consume more than 16 milliseconds per frame.

With the debug GPU overdraw feature, all over-drawing is displayed on the screen in different colors. 1x or 2x over-rendering is not a problem, even a small area of light red is not too bad, but if we see too many red areas on the screen, it may be problematic, let's look at a few examples:

In the example on the left, we see that the list part is green, usually OK, but the area covered above is a red one, so there is a problem. In the example on the right, the entire list is light red. In two examples, there is an opaque list of 2x or 3x over-rendering. These over-drawing may occur when we set a full-screen background for activity or fragment, while also setting a background color for the ListView and ListView entries. You can solve this problem by setting the background color only once.

Note: The default theme will give you a default full-screen background color, and if your activity has another flat background that covers the default background color, you can remove the theme's default background color, which also removes a layer of over-painting. This can be done by configuring the theme configuration or by means of code that calls the GetWindow (). Setbackgrounddrawable (null) method in the OnCreate () method.

With the hierarchy Viewer, you can export a PSD file of all view levels, open in Photoshop, and investigate different layouts and different levels, as well as discover some of the over-drawing that exists in the layout. Using this information, you can remove unnecessary over-painting. Also, do not see the green is satisfied, directed at the blue!

Transparency

Using transparency can affect performance, but to understand why, let's look at what happens when we set the transparency of the view. Let's take a look at the following layout:

We see three imageview in this layout and overlap. When using the most general method of setting transparency Setalpha (), the method is passed to the top of No child view, where each imageview. These imageview will then be drawn into the frame buffer with a new transparent value. And the result is:

This is not the result we want to see.

Because each imageview is given a transparent value, the parts that should be covered are fused together. Fortunately, the system has solved this problem for us. The layout is copied to a non-screen area buffer, and the transparency is received as a whole, and the result is copied to the frame buffer. The result is:

However, we are going to pay the price of performance above.

If it is drawn in the off-screen buffer before drawing in the frame buffer, it is equivalent to adding an invisible layer of paint. The system does not know that we want this transparency to unfold in what form, so the system usually uses a relatively complex one. However, there are many ways to set the transparency to avoid complex operations in the off-screen buffer:

    • TextView-Use the SetTextColor () method instead of Setalpha (). This method uses the alpha channel to change the character color, and the word uses it to draw directly.
    • ImageView-Use the Setimagealpha () method instead of Setalpha (). Principle Ibid.
    • Custom Controls-If your custom controls don't support overwriting each other, it doesn't matter. All sub-view does not want to be the same as in the example above, because of the overlap and integration. by copying Hasoverlappingrendering () and returning it to false, the system is notified that the view is drawn in the most direct way. We can also manually manipulate the logic after setting the transparency by Onsetalpha () to return true.
Hardware acceleration

With the introduction of hardware acceleration (Hardware accleration) in the honeycomb release, our application has a new drawing model when it is drawn. It introduces the displaylist structure, which is used to record the drawing commands of the view for faster rendering. But there are some good feature developers who tend to ignore or use inappropriate--view layers.

Using the view layers (hardware layer), we can render the view into a non-screen area buffer (off-screen buffer, mentioned in the previous Transparency section), and manipulate it according to our needs. This function is mainly for animation, because it can make the complex animation effect more smooth. Instead of using the hardware layer, the view will be refreshed once after the animated properties (such as coordinate, scale, alpha, and so on) have changed. And for a relatively complex view, this refresh will be associated with all of its child view to refresh, and their respective redraw, quite expensive performance. Using view layers, by invoking the hardware layer, the GPU creates a structure directly for our view and does not cause a refresh of the view. And we can do a lot of things with this structure without a flush, such as X/Y position transformation, rotation, transparency, etc. In short, this means that we can animate a complex view without refreshing! This will make the animation look smoother. Here's how we do it:

// Using the Object animatorview.setLayerType(View.LAYER_TYPE_HARDWARE, null);ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(view, View.TRANSLATION_X, 20f);objectAnimator.addListener(new AnimatorListenerAdapter() {    @Override    public void onAnimationEnd(Animator animation) {        view.setLayerType(View.LAYER_TYPE_NONE, null);    }});objectAnimator.start();// Using the Property animatorview.animate().translationX(20f).withLayer().start();

It's simple, right?

Yes, but there are a few things to keep in mind when using hardware layers:

    • Recycle -the hardware layer consumes a chunk of memory in the GPU. Use them only when necessary, such as animations, and pay attention to recycling afterwards. For example, in the Objectanimator example above, we added an animation end listener to remove the hardware layer after the animation has ended. In the case of property animator, we used Withlayers (), which automatically creates the hardware layer at the beginning of the animation and automatically removes it at the end.
    • If you change the viewafter calling the hardware view layers, it will cause the hardware layer to refresh and re-render the view to the non-screen zone cache again. This usually happens when we use properties that are temporarily not supported by the hardware layer (so far, the hardware layer has only been optimized for the following properties: Otation, scale, X/y, translation, pivot, and Alpha). For example, if you perform an animation on another view and use the hardware layer to slide them while the screen changes his background color, this will cause a continuous refresh of the hardware layer. In the case of the performance cost of continuous refresh of the hardware layer, it may become less of a value to use here.

For the second problem, we also have a visual way to see hardware-level updates. Use "Show hardware layers Updates" in Developer's options (show hardware layer updates)

When this option is turned on, the view flashes green when the hardware layer refreshes. A long time ago I had a viewpager that was a little fluid when I slipped. After starting this option in developer mode, I slipped Viewpager again and found the following:

The left and right two pages turn completely green when they slide!

This means that they used the hardware layer when they were created, and the interface was refreshed when they were sliding. And when I use the jet lag effect on the background and have an animated effect on the item, the processing does make it refresh, but I didn't start the hardware layer on the Viewpager. After reading the source code of Viewpager, I found that when sliding, I automatically start a hardware layer for the left and right two pages, and remove it after the swipe is over.

It's understandable to create a hardware layer when sliding between pages, but it's a little unfortunate for me. In general, the hardware layer is added to allow Viewpager to slide more smoothly, after all, they are relatively complex. But this is not what my app wants, and I have to use some coding to remove the hardware layer.

Hardware layers are not really cool stuff. It is important that we understand his principles and use them wisely, otherwise you will be in some trouble.

Diy

In preparing this series of examples, I did a lot of coding to simulate these scenarios. You can find the code in this GitHub project, and you can find it on Google Play. I use different activity to distinguish between different situations and try to explain their documentation to help you understand what kind of problem is occurring in different activity. While you can read the Javadoc of each activity, use the tools we mentioned earlier to play the app.

More information

As the Android system evolves, you have a lot to say about your application. Many new tools were introduced into the SDK, and some new features were added to the system (like the hardware layer). So it is very important to keep pace with the times and to know the choice.

This is a great tubing playlist, called Android performance Patterns, some short videos produced by Google, explaining a lot of performance-related topics. You can find comparisons between different data structures (HASHMAP vs arraymap), bitmap optimization, network optimization and so on, vomiting blood recommendation!

Join the g+ community of Android performance patterns to discuss, share, and ask questions!

More Interesting links:

    • Learn about the wirelessly graphics structure (graphics Architecture). For example, about UI rendering, different system components, such as Surfaceflinger, and how they interact with each other. It's long, but it's worth a look!
    • A speech on the Google IO 2012 shows how the Drawing model works.
    • A study of the performance of Anrdroid from Devoxx 2013 shows some optimizations for the drawing model in Anrdroid 4.4, and demonstrates the use of different optimization tools in the form of demos (Systrace,overdraw, etc.).
    • A very good article on "Preventative optimization" (preventative Optimizations), which illustrates the difference between him and "immature optimization". Many developers do not optimize their code, because they think these effects are not obvious. But remember, the problem is a few things. If you have the opportunity to optimize a small point, even a very insignificant point, it should be.
    • Wirelessly memory Management-a 2011-year Google IO video is still worth a look. The video shows how Android manages the memory of different apps and how to use eclipse mat to discover problems.
    • A case study of a Google engineer called Romain Guy, by optimizing a third-party Twitter client. In this study, Romain showed how he found the problem, and suggested the corresponding solution. Another article followed up on this issue, showing some of the other issues behind the app's re-creation.

I sincerely hope that you get enough information and confidence through this article, and start today to optimize your application!

Try using the tool to record and go through some of the options in the developer's options to get started. Welcome to g+ to share your experience on Android performance optimization!

Acceleration for your App-Android optimizer guide

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.