background preloader

Android velib

Facebook Twitter

Memory Leaking of Android Application caused by View.setTag(int, obj) « Paranoid Android. Memory Leaking of Android Application caused by View.setTag(int, obj) Activity (and associated views) Leaks Found that the implementation of View.setTag(int, object) has bug that may possibly cause memory leak.

Memory Leaking of Android Application caused by View.setTag(int, obj) « Paranoid Android

Did a quick search in Google and found that I am not alone. This guy noticed that the problem is because of private static WeakHashMap<View, SparseArray> sTags; Update: Download test project file. and whenever a View has a tag referenced the View it will cause the memory leak. Version A: Version B: test method I run both versions on my phone, and I rotate my phone several times to cause the activity to stop and create again. Result version A Version A is fine, even the circular reference is not too direct, it still managed to gc and only one instance of the Activity is present. Version B On the other hand, Version B leaves a number of copies of Activity in memory (well, exactly the same as the times I rotated the phone). Implication Like this: Like Loading... Android Tabs with interacting map and list views « Josh Thought. Last tutorial, we wrote a simple app that displays two interacting list views in a TabActivity.

Android Tabs with interacting map and list views « Josh Thought

In this tutorial, we will up the ante and add a MapView as the content of one of the tabs. Why again are we using multiple views in an activity instead of using a separate activity for each tab content? Remember, we want our tabs to be able to easily interact with one another, and keeping them as views allows us to handle the logic and interaction within one activity. So, our goal in this tutorial is to have a list of geo coordinates and when we click on an item in the list, our map view goes to that location. First off, let’s create an XML layout that contains a TabHost, TabWidget, a ListView, and a MapView. Once we have a layout, we need to create our main Activity. Why is this? Let’s create a class called TabbedListMapActivity and have it extend MapActivity. Next, we want to extract our ListView from the XML, set it to a member variable, and add some initial coordinates to its list adapter. Designing for Performance.

This document primarily covers micro-optimizations that can improve overall app performance when combined, but it's unlikely that these changes will result in dramatic performance effects.

Designing for Performance

Choosing the right algorithms and data structures should always be your priority, but is outside the scope of this document. You should use the tips in this document as general coding practices that you can incorporate into your habits for general code efficiency. There are two basic rules for writing efficient code: Don't do work that you don't need to do. Don't allocate memory if you can avoid it. One of the trickiest problems you'll face when micro-optimizing an Android app is that your app is certain to be running on multiple types of hardware. To ensure your app performs well across a wide variety of devices, ensure your code is efficient at all levels and agressively optimize your performance.

Avoid Creating Unnecessary Objects Object creation is never free. Prefer Static Over Virtual Always Measure. Ch03. Oracle Technology Network > Java Software Downloads View All Downloads Top Downloads New Downloads What's New Java in the Cloud: Rapidly develop and deploy Java business applications in the cloud.

ch03

Essential Links Developer Spotlight Java EE—the Most Lightweight Enterprise Framework? Blogs Technologies Contact Us About Oracle Cloud Events Top Actions News Key Topics Oracle Integrated Cloud Applications & Platform Services.