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

  • SEARCH
  • Home
  • 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 6801779
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:08:31+00:00 2026-05-26T19:08:31+00:00

I’ve been tracking down potential memory leaks in my Android application, and I’ve come

  • 0

I’ve been tracking down potential memory leaks in my Android application, and I’ve come across one that I’m not sure what to do with. First, I’ll describe what I’m trying to do.

For what it’s worth, I’m building for Eclair (2.1, API level 7) and testing on an HTC Incredible running Gingerbread (2.3.7, API level 10). From observing LogCat, I assume my application has a maximum heap size of about 32MB.

I am trying to build an address book wherein you have several pages of contacts. You navigate between pages by scrolling left and right, and you navigate through the current page by scrolling up and down. To accomplish this, I am using a Gallery whose adapter adapts a contact list into a ListView, whose adapter in turn adapts a single contact into a RelativeLayout.

Everything seems to be working fine, but I’m running out of native (external) memory really quickly when swiping through the gallery. I made an HPROF dump after swiping around the Gallery for awhile and pulled it into MAT. In the Histogram, I found that I had a few hundred of my contact RelativeLayouts which were held onto solely by my contact ListViews. Here’s what I found when I looked at the [truncated] MAT merge_shortest_paths output of that ListView:

android.view.ViewRoot$1
+ this$0 android.view.ViewRoot
  + mAttachInfo android.view.View$AttachInfo
    + mScrollContainers java.util.ArrayList
      + array java.lang.Object[303]
        + [110], [112], [114], [116], [118], ... com.example.LeakyListView
        + ...and so forth.

The only thing holding onto those leaked ListViews was this android.view.View$AttachInfo‘s mScrollContainers field. Problem is, I don’t know how my views are getting in there in the first place, so I’m at a loss on how to plug this leak.

How do I solve this memory leak? Or at the very least, how did this reference chain get built and what is ViewRoot, AttachInfo, and mScrollContainers?

I’ll try and isolate it to a simple test case and post code here soon, but I’m hoping this is enough to get the conversation started.

  • 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-26T19:08:32+00:00Added an answer on May 26, 2026 at 7:08 pm

    You really, really should use ViewPager instead of Gallery for this kind of thing: http://android-developers.blogspot.com/2011/08/horizontal-view-swiping-with-viewpager.html

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I'm trying to create an if statement in PHP that prevents a single post
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm working with an upstream system that sometimes sends me text destined for HTML/XML

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.