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 7457873
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T13:22:40+00:00 2026-05-29T13:22:40+00:00

I have one question. I made quick search on the site, but don’t found

  • 0

I have one question. I made quick search on the site, but don’t found answer.
We develop application that running android 2.2 and higher. For views customization we use many drawables, that used in such way:

<LinearLayout ...
    android:background="@drawable/some_drawable"/>

We use maps too and manipulate with many data in the memory, and our app got a heavy. On top devices, it work’s great,but on other we got OutOfMemory exception after some minutes of using our application. It’s look as we have memory leaks.
I’m trying reduce the memory usage of our app. question, do we need manualy cleaning resources on destroing our activities: removes drawables for view, or system made it for us?

  • 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-29T13:22:41+00:00Added an answer on May 29, 2026 at 1:22 pm

    I have encountered this issue in my app as well. OutOfMemoryError would be thrown if a lot of bitmaps were used in an activity, with scaling and/or other bitmap manipulation. What I have done is added the following code to my activity, which seems to make the problem appearing less often (it didn’t solve it for good) and the app now runs with no errors on a reasonably low-end handset.

    @Override
    protected void onDestroy()
    {
        super.onDestroy();
        // explicitly release media player
        if(viewObjectInfo != null)
            viewObjectInfo.releaseMediaPlayer();
        //explicitly release all drawables and call GC
        unbindDrawables(findViewById(R.id.main));
        System.gc();
    }
    
    /**
     * Unbinds all drawables in a given view (and its child tree).
     * 
     * @param findViewById     Root view of the tree to unbind
     */
    private void unbindDrawables(View view) {
        if (view.getBackground() != null) {
            view.getBackground().setCallback(null);
        }
    
        if (view instanceof ViewGroup) {
            for (int i = 0; i < ((ViewGroup) view).getChildCount(); i++) {
                unbindDrawables(((ViewGroup) view).getChildAt(i));
            }
            try
            {
                ((ViewGroup) view).removeAllViews();
            }
            catch(UnsupportedOperationException ignore)
            {
                //if can't remove all view (e.g. adapter view) - no problem 
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have one question; In my ASP.NET MVC web application have to do certain
Edit 4/4/12 I STILL HAVE ONE QUESTION: I solved my issue but it adds
I want to implement this view But I have one question: The text which
I have made an application that displays a lot of questions from my database.
I have one problem. I have made solution and it is 3-tier application. So
I'm terribly bad at keeping MySQL queries straight, but that aside I have one
Quick question. I have been Googling this all morning, but it's either not there,
I have a bug in my code that made me think I don't fully
Quick embrassing question. I have been looking for a PHP function that would calculate
Just a simple question: I have read that a class should be made static

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.