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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T20:03:26+00:00 2026-06-18T20:03:26+00:00

I have a routine that manipulates a Bitmap to convert form RGB to Grayscale.

  • 0

I have a routine that manipulates a Bitmap to convert form RGB to Grayscale.

It works fine usually, but when I try to use it on a Bitmap which is 1088kb in size it gives me this Error:

java.lang.OutOfMemoryError

I am using the Emulator. 1088kb is not a very big picture, how can it be exhausting the memory?

To be precise the application that does invoke the problematic code includes another Activity on the back-stack that has a ListView of pictures thumbnails.

This is the method:

public Bitmap toGrayscale(Bitmap bmpOriginal)
{        
    int width, height;
    height = bmpOriginal.getHeight();
    width = bmpOriginal.getWidth();    

    Bitmap bmpGrayscale = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565);
    Canvas c = new Canvas(bmpGrayscale);
    Paint paint = new Paint();
    ColorMatrix cm = new ColorMatrix();
    cm.setSaturation(0);
    ColorMatrixColorFilter f = new ColorMatrixColorFilter(cm);
    paint.setColorFilter(f);
    c.drawBitmap(bmpOriginal, 0, 0, paint);
    return bmpGrayscale;
}
  • 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-06-18T20:03:27+00:00Added an answer on June 18, 2026 at 8:03 pm

    You are being very inefficient in managing bitmaps in memory and you likely have a memory leak (not freeing bitmaps from memory when you are done with them or keeping them around in activities that don’t get garbage collected). The Android Developers have a page for proper bitmap management:

    http://developer.android.com/training/displaying-bitmaps/index.html

    You can try increasing the Heap size on your emulator.

    Out of memory error on android emulator, but not on device

    Monitor the heap size on your emulator:

    https://stackoverflow.com/a/7427803/445131

    Get rid of your memory leaks:

    What Android tools and methods work best to find memory/resource leaks?

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

Sidebar

Related Questions

I have this routine that works well, but it messes up as it counts
I have a routine that takes a list of strings as a parameter, but
I have created a Word Merge routine that i use personally. When I add
I am doing some basic Socket messaging. I have a routine that works well
I have a routine that examines thousands of records looking for discrepancies. This can
I have a routine that dynamically changes a select list's selected option when the
I'm developing an MVC application and I have a routine that gets the currently
I have a jquery routine that calls an MVC action which will do a
I have a bunch of code in a routine that looks a bit like
Good Day, I have a simple working routine in Perl that swaps two words:

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.