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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:22:23+00:00 2026-05-20T10:22:23+00:00

I’ve spent the morning reading through page after page of StackOverflow posts about this

  • 0

I’ve spent the morning reading through page after page of StackOverflow posts about this exact error, but the root cause of their problems always seems to be either 1) they have very large images which need to be down sampled or 2) they are suffering after one or more device rotations which cause the activity to be destroyed and recreated several times.

I’m getting this error (only very rarely), but my app only allows portrait orientation so no rotations are possible and all of my images are very small. I do have many images, but they are all very small. It is a calculator app, so there are images for each button. The images are only 1.9k for the mdpi and 2.8k for the hdpi. These are tiny, tiny images. I processed them through Photoshop to downsample all of them to 8bit PNGs. Here is an example of one of my images: http://geekqi.com/StackOverflow/OutOfMemoryImage.png

There are about 80 of these ImageButtons (only 40 of which are on the screen at once). I have two views, each with 40 ImageButtons and when you press a button, one of the views is hidden and the other shown (offering a Shift functionality to allow access to more functions). Each button has a standard image and a highlighted image. So, all in all I’m dealing with 160 tiny images. The biggest one is 2.8k so 160 of them would be 448k… even if the ImageButton overhead would double that size, it’s less than 1MB.

Below is the stacktrace I’m receiving. It references line 296, which looks like:

<ImageButton android:id="@+id/buttonRND" android:src="@drawable/image_rnd" android:hapticFeedbackEnabled="true" style="@style/CalculatorButton"/>

Here is the stack trace I’m dealing with:

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mydomain.myapp/com.mydomain.myapp.CalculatorTabActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mydomain.myapp/com.mydomain.myapp.MyCalculator}: android.view.InflateException: Binary XML file line #296: Error inflating class <unknown>
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
       at android.app.ActivityThread.access$2300(ActivityThread.java:125)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loop(Looper.java:123)
       at android.app.ActivityThread.main(ActivityThread.java:4627)
       at java.lang.reflect.Method.invokeNative(Native Method)
       at java.lang.reflect.Method.invoke(Method.java:521)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:871)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:629)
       at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mydomain.myapp/com.mydomain.myapp.MyCalculator}: android.view.InflateException: Binary XML file line #296: Error inflating class <unknown>
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
       at android.app.ActivityThread.startActivityNow(ActivityThread.java:2503)
       at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:127)
       at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:339)
       at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:651)
       at android.widget.TabHost.setCurrentTab(TabHost.java:323)
       at android.widget.TabHost.addTab(TabHost.java:213)
       at com.mydomain.myapp.CalculatorTabActivity.setupTab(CalculatorTabActivity.java:191)
       at com.mydomain.myapp.CalculatorTabActivity.onCreate(CalculatorTabActivity.java:95)
       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
       ... 11 more
Caused by: android.view.InflateException: Binary XML file line #296: Error inflating class <unknown>
       at android.view.LayoutInflater.createView(LayoutInflater.java:513)
       at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:621)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:621)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:621)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
       at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:210)
       at android.app.Activity.setContentView(Activity.java:1647)
       at com.mydomain.myapp.MyCalculator.configureActivity(MyCalculator.java:1042)
       at com.mydomain.myapp.MyCalculator.onCreate(MyCalculator.java:1111)
       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
       ... 21 more
Caused by: java.lang.reflect.InvocationTargetException
       at android.widget.ImageButton.<init>(ImageButton.java:78)
       at java.lang.reflect.Constructor.constructNative(Native Method)
       at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
       at android.view.LayoutInflater.createView(LayoutInflater.java:500)
       ... 36 more
Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
       at android.graphics.Bitmap.nativeCreate(Native Method)
       at android.graphics.Bitmap.createBitmap(Bitmap.java:468)
       at android.graphics.Bitmap.createBitmap(Bitmap.java:435)
       at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:340)
       at android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:590)
       at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:564)
       at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:425)
       at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:697)
       at android.content.res.Resources.loadDrawable(Resources.java:1709)
       at android.content.res.Resources.getDrawable(Resources.java:581)
       at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:162)
       at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:787)
       at android.graphics.drawable.Drawable.createFromXml(Drawable.java:728)
       at android.content.res.Resources.loadDrawable(Resources.java:1694)
       at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
       at android.widget.ImageView.<init>(ImageView.java:118)
       at android.widget.ImageButton.<init>(ImageButton.java:82)
       ... 40 more

I’ve read through all of the links about tracking down Android memory “leaks”, but they also deal with rotation and my app doesn’t allow rotation.

What can I do to find and fix this problem?

  • 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-20T10:22:24+00:00Added an answer on May 20, 2026 at 10:22 am

    You don’t need to rotate app to get Activity restarted. It is enough to start another activity and then start the original one.

    Do you keep references to your images inside your activity? How do you keep them? In fields? Are you referencing image drawables?

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

Sidebar

Related Questions

I need to clean up various Word 'smart' characters in user input, including but
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
i want to parse a xhtml file and display in UITableView. what is the
public static bool CheckLogin(string Username, string Password, bool AutoLogin) { bool LoginSuccessful; // Trim

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.