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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T23:03:37+00:00 2026-06-03T23:03:37+00:00

i tried writing some camera intent handler for taking pictures and post-precessing them (if

  • 0

i tried writing some camera intent handler for taking pictures and post-precessing them (if needed). If i take some pictures on high-resolution my programm break with “allocation too large”. if i take some with lower resolution i’m able to take more but it’ll break too. After some search i found out that i have to recycle bitmaps i’d made manualy. but the problem didn’t disapear. my main problem is that i don’t know if there is 1. a memory leak in my code 2. i don’t know why it’s trying to allocate the momory cause i don’t show the bitmaps in my programm (for now), i just save them for further reuse.

public void onClick(View view) {
    Intent i = new Intent("android.media.action.IMAGE_CAPTURE");
    this.mLastPic = new File(this.mFs.getDirPath(), this.mFs.getNextPicName()); //create and save a file for pic
    i.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(this.mLastPic));
    this.startActivityForResult(i, 0);
}

the on activty result handler

public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if(resultCode == Activity.RESULT_OK && requestCode == 0) {

        try {
            if(!this.mController.getSetting(R.string.USE_HEIGH_RESOLUTION)) { //use high res or not
                int quality = this.mFs.getPicQuality(); //get compress quality
                Bitmap pic = BitmapFactory.decodeFile(this.mLastPic.getPath());
                ByteArrayOutputStream outStream = new ByteArrayOutputStream();
                pic.compress(Bitmap.CompressFormat.JPEG, quality, outStream);
                String path = this.mLastPic.getPath();
                if(this.mLastPic.delete()) { //replace the old file with a now file
                    File newFile = new File(path);
                    newFile.createNewFile();
                    FileOutputStream os = new FileOutputStream(newFile);
                    os.write(outStream.toByteArray());
                    Log.d("newEntryActivity.onActivityResult", "replaced pic ");
                } else {
                    Log.d("newEntryActivity.onActivityResult", "cant delete old pic");
                }
                pic.recycle(); //cleaning up
                outStream.close();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}

logcat shows

05-09 14:35:01.694: E/dalvikvm-heap(845): 6380496-byte external allocation too large for this process. 05-09 14:35:01.694: E/(845): VM won’t let us allocate 6380496 bytes

05-09 14:35:01.694: D/AndroidRuntime(845): Shutting down VM

05-09 14:35:01.694: W/dalvikvm(845): threadid=3: thread exiting with uncaught exception (group=0x4001b188)

05-09 14:35:01.694: E/AndroidRuntime(845): Uncaught handler: thread main exiting due to uncaught exception

05-09 14:35:01.714: E/AndroidRuntime(845): java.lang.RuntimeException: Unable to start activity ComponentInfo{unicorn.Heurazio/unicorn.Heurazio.SettingsActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class …

05-09 14:35:01.714: E/AndroidRuntime(845): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class

05-09 14:35:01.714: E/AndroidRuntime(845): at android.view.LayoutInflater.createView(LayoutInflater.java:513)

05-09 14:35:01.714: E/AndroidRuntime(845): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)

05-09 14:35:01.714: E/AndroidRuntime(845): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)

05-09 14:35:01.714: E/AndroidRuntime(845): at android.view.LayoutInflater.inflate(LayoutInflater.java:385)

05-09 14:35:01.714: E/AndroidRuntime(845): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)

05-09 14:35:01.714: E/AndroidRuntime(845): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)

05-09 14:35:01.714: E/AndroidRuntime(845): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)

05-09 14:35:01.714: E/AndroidRuntime(845): at android.app.Activity.setContentView(Activity.java:1622)

05-09 14:35:01.714: E/AndroidRuntime(845): at unicorn.Heurazio.SettingsActivity.onCreate(SettingsActivity.java:38)

05-09 14:35:01.714: E/AndroidRuntime(845): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)

05-09 14:35:01.714: E/AndroidRuntime(845): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)

05-09 14:35:01.714: E/AndroidRuntime(845): … 11 more

05-09 14:35:01.714: E/AndroidRuntime(845): Caused by: java.lang.reflect.InvocationTargetException

05-09 14:35:01.714: E/AndroidRuntime(845): at android.widget.LinearLayout.(LinearLayout.java:92)

05-09 14:35:01.714: E/AndroidRuntime(845): at java.lang.reflect.Constructor.constructNative(Native Method)

05-09 14:35:01.714: E/AndroidRuntime(845): at java.lang.reflect.Constructor.newInstance(Constructor.java:446)

05-09 14:35:01.714: E/AndroidRuntime(845): at android.view.LayoutInflater.createView(LayoutInflater.java:500)

05-09 14:35:01.714: E/AndroidRuntime(845): … 21 more

05-09 14:35:01.714: E/AndroidRuntime(845): Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget

05-09 14:35:01.714: E/AndroidRuntime(845): at android.graphics.Bitmap.nativeCreate(Native Method) > 05-09 14:35:01.714: E/AndroidRuntime(845): at android.graphics.Bitmap.createBitmap(Bitmap.java:468)

05-09 14:35:01.714: E/AndroidRuntime(845): at android.graphics.Bitmap.createBitmap(Bitmap.java:435)

05-09 14:35:01.714: E/AndroidRuntime(845): at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:340)

05-09 14:35:01.714: E/AndroidRuntime(845): at android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:488)

05-09 14:35:01.714: E/AndroidRuntime(845): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:462)

05-09 14:35:01.714: E/AndroidRuntime(845): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:323)

05-09 14:35:01.714: E/AndroidRuntime(845): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:697)

05-09 14:35:01.714: E/AndroidRuntime(845): at android.content.res.Resources.loadDrawable(Resources.java:1705)

05-09 14:35:01.714: E/AndroidRuntime(845): at android.content.res.TypedArray.getDrawable(TypedArray.java:548)

05-09 14:35:01.714: E/AndroidRuntime(845): at android.view.View.(View.java:1850)

05-09 14:35:01.714: E/AndroidRuntime(845): at android.view.View.(View.java:1799)

05-09 14:35:01.714: E/AndroidRuntime(845): at android.view.ViewGroup.(ViewGroup.java:284)

any help would be great.

regards Alex

  • 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-03T23:03:38+00:00Added an answer on June 3, 2026 at 11:03 pm

    After some reading and modifying of my program, like adding a reference to the background in an overloaded application, wiping all unneeded context elements I’ve still the same problem and it seems to be even worser.

    if i can trust my calculation for the size of the bitmap

    Bitmap tmp = BitmapFactory.decodeResource(this.getResources(), R.drawable.logo);
    Log.d("mainApp", tmp.getRowBytes() * tmp.getHeight() / 1024 + "kB");
    

    my 100kB logo (.png) takes 6mB ram (which would fit for the exception message). any ideas would be great.

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

Sidebar

Related Questions

I was writing some codes in linux using c. When tried to compiled, I
I want to get some random text generated. I tried writing a basic Java
I am writing an application that needs pictures taken with the camera. The problem
I tried writing some code like: i = [1, 2, 3, 5, 8, 13]
I am writing some macros that take a function name and do some actions,
I tried writing a program in Java using regex to match a pattern and
I am having trouble creating an entity using inout ports. I tried writing the
I'm trying to learn Lisp (elisp, actually), and I tried writing the following function
I have tried the following program for writing the contents into Spreadsheet. I downloaded
I am writing python script which gets links from website. But when I tried

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.