Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5934407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T15:06:35+00:00 2026-05-22T15:06:35+00:00

I have a ListView that uses a custom adapter. The custom adapter’s getView uses

  • 0

I have a ListView that uses a custom adapter. The custom adapter’s getView uses all the recommended practices:

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    SuscriptionsViewsHolder holder;
    ItemInRootList item = mItemsInList.get(position);

    if (convertView == null) {
         convertView = mInflater.inflate(R.layout.label, null);

         holder = new SuscriptionsViewsHolder();
         holder.label = (TextView) convertView.findViewById(R.id.label_label);
         holder.icon = (ImageView) convertView.findViewById(R.id.label_icon);

        convertView.setTag(holder);
    } else {
        holder = (SuscriptionsViewsHolder) convertView.getTag();
    }

    String text = String.format("%1$s (%2$s)", item.title, item.unreadCount);
    holder.label.setText(text);
    holder.icon.setImageResource(item.isLabel ? R.drawable.folder : R.drawable.file );

    return convertView;
}

However when I scroll, it is sluggish because of heavy garbage collection:

GC_EXTERNAL_ALLOC freed 87K, 48% free 2873K/5447K, external 516K/519K, paused 30ms
GC_EXTERNAL_ALLOC freed 7K, 48% free 2866K/5447K, external 1056K/1208K, paused 29ms
GC_EXTERNAL_ALLOC freed <1K, 48% free 2866K/5447K, external 1416K/1568K, paused 28ms
GC_EXTERNAL_ALLOC freed 5K, 48% free 2865K/5447K, external 1600K/1748K, paused 27ms
GC_EXTERNAL_ALLOC freed <1K, 48% free 2865K/5447K, external 1780K/1932K, paused 30ms
GC_EXTERNAL_ALLOC freed 2K, 48% free 2870K/5447K, external 1780K/1932K, paused 26ms
GC_EXTERNAL_ALLOC freed 2K, 48% free 2870K/5447K, external 1780K/1932K, paused 25ms
GC_EXTERNAL_ALLOC freed <1K, 48% free 2870K/5447K, external 1780K/1932K, paused 26ms
GC_EXTERNAL_ALLOC freed 3K, 48% free 2870K/5447K, external 1780K/1932K, paused 25ms
GC_EXTERNAL_ALLOC freed <1K, 48% free 2870K/5447K, external 1780K/1932K, paused 29ms
GC_EXTERNAL_ALLOC freed <1K, 48% free 2870K/5447K, external 1780K/1932K, paused 29ms
GC_EXTERNAL_ALLOC freed <1K, 48% free 2871K/5447K, external 1780K/1932K, paused 28ms
GC_EXTERNAL_ALLOC freed <1K, 48% free 2871K/5447K, external 1780K/1932K, paused 26ms
GC_EXTERNAL_ALLOC freed <1K, 48% free 2870K/5447K, external 1780K/1932K, paused 27ms
GC_EXTERNAL_ALLOC freed <1K, 48% free 2870K/5447K, external 1780K/1932K, paused 29ms
GC_EXTERNAL_ALLOC freed <1K, 48% free 2870K/5447K, external 1780K/1932K, paused 26ms
GC_EXTERNAL_ALLOC freed <1K, 48% free 2870K/5447K, external 1780K/1932K, paused 34ms

What seems to be wrong?

EDIT @12:47 GMT:

In fact it’s slightly more complicated than this. My app UI is based on 2 parts. One is the brain of a screen, creating the views, handling user input, etc. The other is a Fragment if the device has android 3.0, otherwise it’s an Activity.

The GC happened on my Nexus One 2.3.3 device, so using the Activity. I don’t have my Xoom with me to test the behaviour with a Fragment.

I could post the source if required, but let me try to explain it :

  • RootList is the brain of the UI. It contains :
    • a List<> of items that will be placed in the ListView.
    • a method that builds this list from a SQLite db
    • a custom BaseAdapter that contains basically only the getView method pasted above
  • RootListActivity is a ListActivity, which:
    • uses an XML layout
    • the layout has of course a listview with id android.id.list
    • the Activity callbacks are forwarded to the RootList class using an instance of RootList created when the activity is created (constructor, not onCreate)
    • in the onCreate, I call RootList‘s methods that will create the list of items, and set the list data to a new instance of my custom class derived from BaseAdapter

EDIT on may 17th @ 9:36PM GMT:

Here’s the code of the Activity and the class that does the things. http://pastebin.com/EgHKRr4r

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T15:06:36+00:00Added an answer on May 22, 2026 at 3:06 pm

    I found the issue. My XML layout for the activity was:

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
    
        <include android:id="@+id/rootlist_header" layout="@layout/pre_honeycomb_action_bar" />
    
        <ListView android:id="@android:id/list"
            android:layout_below="@id/rootlist_header"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_weight="1"
            android:textColor="#444444"
            android:divider="@drawable/list_divider"
            android:dividerHeight="1px"
            android:cacheColorHint="#00000000" />
    
    </RelativeLayout>
    

    If I remove the android:cacheColorHint="#00000000", the heavy GC is out, and the scrolling is smooth! 🙂

    I don’t really know why this parameter was set, because I don’t need it. Maybe I copypasted too much instead of actually build my XML layout.

    THANK YOU for your support, I really appreciate your help.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a custom ListView that uses a custom ArrayAdapter (which basically just overrides
I have a custom control that is derived from ListView . This list view
I have a ListView that uses Linkify to create a link to another activity
I have a ListView on a page that uses a object data source. I
I have a listview that uses a customadapter based on the baseadapter. The listview
I have a ListView that uses different XML files to create Views and make
I have a listview in WPF and C# that uses an ObservableCollection to populate
I have a listview and a button next to it that uses the selected
I have an Activity that uses a ListView to simply display a list of
I have a listview that is binded to a ThreadSafeObservableCollection. The background of each

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.