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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:39:46+00:00 2026-05-28T05:39:46+00:00

I am getting the error java.lang.OutOfMemoryError: bitmap size exceeds VM budget . This occurs

  • 0

I am getting the error java.lang.OutOfMemoryError: bitmap size exceeds VM budget.

This occurs when creating a bitmap for the purpose of manually drawing a line graph.

width = display.getWidth() - 10;
height = width * 4 / 5;
Bitmap emptyBmap = Bitmap.createBitmap(width, height, Config.ARGB_8888);
Bitmap charty = createMyGraphAndStuff(emptyBmap);

It looks like the total memory allocated was about 700 Kb, an unreasonable amount.

I’ve seen other solutions invoked when creating bitmaps from a file, but here I am generating one myself. How can I minimize its memory footprint?

Here’s some more code to give you a better idea of what it’s doing:

public Bitmap DrawTheGraphAndStuff(Bitmap bitmap, String[] scores)
{
        Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Config.ARGB_8888);
        Canvas canvas = new Canvas(output);

        drawTheGridLines(canvas);                                   

        plotTheDataPoints(canvas ,  scores ,  "the title" , 0 );    

        canvas.drawBitmap(bitmap, rect, rect, paint);

        return output;
}
  • 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-28T05:39:47+00:00Added an answer on May 28, 2026 at 5:39 am

    when the OOM occur, give some advice:

    1.need know the oom occur position, the log information is enough

    2.the most time is the bitmap process, so you need know how much a image about used memory:

    the formula: w * h * every pixel token memory in byte, if the Config is Config.ARGB_8888, every pixel token memory is 4bytes, if it is the Config.RGB_565, is 2bytes.

    3.also, you need know the every app memory limits in your device:

       ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
       activityManager.getMemoryClass(); //return the memory size limit in MB
    

    3.if the bitmap did not used again, try recyle() it

    4.if began the bitmap process, the memory is almost the max memory limit, so use the adb shell dumpsys meminfo $pid to check the memory usage, also the ddms - allocation tracker is useful

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

Sidebar

Related Questions

I am getting the 'java.lang.OutOfMemoryError: bitmap size exceeds VM budget' error... What I am
java.lang.OutOfMemoryError: bitmap size exceeds VM budget. i am updating images to a gridview from
I'm getting a lot of these exceptions from users: java.lang.OutOfMemoryError: bitmap size exceeds VM
I am getting this error: Exception in thread main java.lang.OutOfMemoryError: Java heap space at
I'm simulating a overload of a server and I'm getting this error: java.lang.OutOfMemoryError: unable
First off, this is the error I am getting java.lang.OutOfMemoryError at coderaustin.com.FileEncryptor.encryptFile(FileEncryptor.java:56) at coderaustin.com.Main.onCreate(Main.java:41)
I am getting this out of memory error: java.lang.RuntimeException: java.lang.OutOfMemoryError: <classname>: Unable to expand
I keep getting this error? 07-25 17:04:00.796: ERROR/AndroidRuntime(420): Caused by: java.lang.OutOfMemoryError 07-25 17:04:00.796: ERROR/AndroidRuntime(420):
I am getting an OutOfMemoryError. How do I solve this? Error: java.lang.OutOfMemoryError: Java heap
I am getting the following error on execution of a multi-threading program java.lang.OutOfMemoryError: Java

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.