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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T02:40:53+00:00 2026-06-07T02:40:53+00:00

I am drawing a frame by frame animation to a canvas and I have

  • 0

I am drawing a frame by frame animation to a canvas and I have about 100 pics that I’m using to do this (which is about 1.5MB total). I started out by just doing this:

s000 = BitmapFactory.decodeResource(getResources(), R.drawable.s0);
s001 = BitmapFactory.decodeResource(getResources(), R.drawable.s1); ...etc...

to every image and then drawing each image to the canvas:

c.drawBitmap(s000, X, Y, null);

to make an animation.

The problem is that I get this error “OutOfMemoryError: bitmap size exceeds VM budget”. How would I load all the pics without getting this error? Is 1.5MB to much memory or do I have a memory leak? What would I do to fix the memory leak?

Thank you very much for your help. I am noob with android so could you please leave examples and not just tell me to do something that I wont understand 🙂 Thanks again

  • 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-07T02:40:54+00:00Added an answer on June 7, 2026 at 2:40 am

    Try like this for every frame you draw:

    s000 = BitmapFactory.decodeResource(getResources(), R.drawable.s0);
    c.drawBitmap(s000, X, Y, null);
    s000.recycle();
    s000 = null;
    

    This will try to release the memory after drawing the frame.

    EDIT

    myImgLen = 30;
    Bitmap bitmap = null;
    for (int i = 0; i < myImgLen; i++) {
        bitmap = BitmapFactory.decodeResource(getResources(), getResource‌​s().getIdentifier("s" + i, "drawable", getPackageName()));
        c.drawBitmap(bitmap, X, Y, null);
        bitmap.recycle();
        bitmap = null;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this class that im getting the information from the animated gif: using
I'm drawing a 3d scene in 5-6 drawcalls, but I have about 60000-65000 triangles
I am drawing a graph on a <canvas> that requires expensive calculations. I would
I have a html 5 canvas using the 2d context. I am able to
I'm making a frame which contains a round rectangle. This rectangle is constantly (re)painting
If I have a frame buffer which has a textured binded to it which
I am having trouble drawing an animation on a HTML 5 canvas inside a
Drawing a blank on this, and google was not helpful. Want to make a
This drawing shows a tree of parent-child relationships. It is directed, without cycles. A
I have an overview drawing of a plant and I want to show the

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.