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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:39:47+00:00 2026-06-10T14:39:47+00:00

I have a very strange bug. It only happens in the Emulator. I tested

  • 0

I have a very strange bug. It only happens in the Emulator. I tested it on multiple Android phones and the Acer Tablet, it works fine there.

My program has a loop that loads in Bitmaps into a Bitmap[] bitCards. The Array is set up for 14 elements by bitCards = new Bitmap[14].

Now it loops 12 times to put a Bitmap into the Array as follows:

bitCards[i] = BitmapFactory.decodeStream(inputStream);

When i = 8 it crashes at this statement.

If i replace it with

bitCards[0] = BitmapFactory.decodeStream(inputStream);

it does not crash, I thought maybe somehow the Array was not big enough so I did the following

bitCards[8]=BitmapFactory.decodeStream(inputStream); // Still did not crash.

The only thing that makes sense is that when I have

bitCards[i] = BitmapFactory.decodeStream(inputStream);

It is relasing the old memory and putting in a new object, thus only memory for one object is created, but…. the exception does not go off, shouldn’t I get some kind of an error?

Here is my full code:

void Shuffle()
{
    Random generator;
    generator = new Random();
    int[] iCardsUsed;
    iCardsUsed = new int[55];
    for(int i=0;i<55;i++)
    iCardsUsed[i]=0;

    try {   

        bitCards = new Bitmap[14];
        iCards = new int[14];
        iTurnOver = new int[14];

        for (int i = 0; i < 12; i++)
        {
            iTurnOver[i]=0;

            int cardId;

            do {
                cardId = generator.nextInt(50);
            } while( iCardsUsed[cardId] ==1);

            iCardsUsed[cardId] =1;
            iCards[i]=cardId;

            iCards[i]=i;    
            String fName=new String("card");
            fName+=Integer.toString(iCards[i]+1);
            fName+=".jpg";

            AssetManager assetManager= ctx.getAssets();
            InputStream inputStream;
            inputStream = assetManager.open(fName);

            // this is where it crashes
            bitCards[i]=BitmapFactory.decodeStream(inputStream);

            inputStream.close();    
        }

    } catch( IOException e)
    {
        gi++;
    }
    // update screen
    invalidate();
}
  • 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-10T14:39:49+00:00Added an answer on June 10, 2026 at 2:39 pm

    Since you have provided no error message, I am taking a shot in the dark and assuming it is going OOM.

    You say that it stops after running for a few times ( when i = 8) , I believe that you are not freeing the resources. Bitmaps can sometime take up a lot of space and if you are persisting them in the memory, I would not be surprised if the device goes OutOfMemory. Different devices have different specs for memory and after a few runs it is filling up the memory.

    So, my suggestion would be to clear the Bitmaps, using mBitmap.recycle(), and the other storage that you are using for temporary purposes.

    Also, have a look at this question!

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

Sidebar

Related Questions

I have a very strange bug, which I believe is caused by some code
I have a very strange issue. I have an open WebSocket, the communication works
I am developing an Android application with MapView and I have a very strange
I have a very strange bug going on. I cannot get the flyout to
I have encountered a very strange bug in Firefox. I have a javascript function
I have a very strange bug in a shipping iPad/iPhone app that I can't
I'm experimenting with CUDA and I ran into a very strange bug. I have
I have isolated very strange bug from our current project: index.html (demo) and iframe.html
I have very strange problem while I am submitting a practice problem on codechef.
I have very strange behaviour of Java Date class: System.out.println(new Date().toGMTString()); long l =

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.