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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:48:21+00:00 2026-05-24T02:48:21+00:00

Hi Stackoverflow friends, I need an appliaction that ,capture an image using camera and

  • 0

Hi Stackoverflow friends,

I need an appliaction that ,capture an image using camera and display it in an image view repeatedly.After taking the picture i send this picture to the server.For this process i’m using AsynTask class named myBackgroundUploader. When i click the button i calls the Asysnctask.I done it but after taking 2 three pictures I got outofmemory error and my app force closed. I tried to recycle(),null values but no use. Can any one tell how to avoid this error .This is the log i have got.

    onCreate()
    {
    setContentView(R.layout.detail_profile);

    String fname=new File(getFilesDir(), "MyFile.jpeg").getAbsolutePath();
     if(imgView!=null)
               {
                   imgView.destroyDrawingCache();
               }
                imgView=(ImageView)findViewById(R.id.imageView1);
                imgView.setImageURI(Uri.fromFile(new File(fname)));

    }


public void onClick(View v) {

                 if(checkInternetConnection()==false)
                {
                     new AlertDialog.Builder(detailProfile.this).setTitle("Warning!").setMessage("No Internet connection").setIcon(R.drawable.icon).setNeutralButton("Close", null).show();

                }   if(diTask!=null)
                        {
                            AsyncTask.Status diStatus=diTask.getStatu();
                            if(diStatus!=AsyncTask.Status.FINISHED)
                            {
                                return;
                            }

                        }
                        fileprocess();
                        diTask=new myBackgroundUploader(detailProfile.this);
                        diTask.execute("url for server");

}

 myBackgroundUploader.java

protected void onPreExecute()
    {

        progDailog = ProgressDialog.show(mcontext,
                "Syncing with server ", "Please wait....",
                true);

    }
    protected Bitmap doInBackground(String...pram)
    {
        Log.v("doback","uploading,,");

        uploadImage(pram[0]); //here parm[0]is my server url
        return null;

    }
    protected void onPostExecute(Bitmap bm)
    {

    }

    public void uploadImage(String...urls)
    {
         String fname=new File(mcontext.getFilesDir(),"MyFile.jpeg").getAbsolutePath();
Bitmap testAB=null;
        BitmapFactory.Options options= new BitmapFactory.Options();
        options.inSampleSize = 4;
        testAB=BitmapFactory.decodeFile(fname, options);


        ByteArrayOutputStream bao = new ByteArrayOutputStream();
        testAB.compress(Bitmap.CompressFormat.JPEG,50, bao);
        byte [] ba = bao.toByteArray();
        String ba1=Base64.encodeBytes(ba);
        ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
        nameValuePairs.add(new BasicNameValuePair("image",ba1));
        nameValuePairs.add(new BasicNameValuePair("address",detailProfile.address.getText().toString()));


        HttpClient httpclient = new DefaultHttpClient();
        HttpPost httppost = new HttpPost(urls[0]);
        HttpParams param=new BasicHttpParams();
        HttpConnectionParams.setSoTimeout(param, 60000);
        httppost.setParams(param);
        httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
        HttpResponse response = httpclient.execute(httppost);
        HttpEntity entity = response.getEntity();
        is =entity.getContent();
        progDailog.dismiss();
        //urls[0].recycle();
        ba=null;
        ba1=null;
        bao.flush();
        testAB.recycle();


      }



07-25 15:39:38.613: ERROR/dalvikvm-heap(31423): 9830400-byte external allocation too large for this process.
07-25 15:39:38.640: ERROR/GraphicsJNI(31423): VM won't let us allocate 9830400 bytes
07-25 15:39:38.640: DEBUG/dalvikvm(31423): GC_FOR_MALLOC freed 1K, 48% free 2904K/5511K, external 21335K/23354K, paused 16ms
07-25 15:39:38.644: DEBUG/skia(31423): --- decoder->decode returned false
07-25 15:39:38.656: WARN/dalvikvm(31423): threadid=9: thread exiting with uncaught exception (group=0x40015560)
07-25 15:39:38.664: ERROR/AndroidRuntime(31423): FATAL EXCEPTION: AsyncTask #1
07-25 15:39:38.664: ERROR/AndroidRuntime(31423): java.lang.RuntimeException: An error occured while executing doInBackground()
07-25 15:39:38.664: ERROR/AndroidRuntime(31423):     at android.os.AsyncTask$3.done(AsyncTask.java:200)
07-25 15:39:38.664: ERROR/AndroidRuntime(31423):     at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:274)
07-25 15:39:38.664: ERROR/AndroidRuntime(31423):     at java.util.concurrent.FutureTask.setException(FutureTask.java:125)
07-25 15:39:38.664: ERROR/AndroidRuntime(31423):     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:308)
07-25 15:39:38.664: ERROR/AndroidRuntime(31423):     at java.util.concurrent.FutureTask.run(FutureTask.java:138)
07-25 15:39:38.664: ERROR/AndroidRuntime(31423):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
07-25 15:39:38.664: ERROR/AndroidRuntime(31423):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
07-25 15:39:38.664: ERROR/AndroidRuntime(31423):     at java.lang.Thread.run(Thread.java:1019)


07-25 15:39:38.664: ERROR/AndroidRuntime(31423): Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
07-25 15:39:38.664: ERROR/AndroidRuntime(31423):     at android.graphics.BitmapFactory.nativeDecodeStream(Native Method)
07-25 15:39:38.664: ERROR/AndroidRuntime(31423):     at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:470)
07-25 15:39:38.664: ERROR/AndroidRuntime(31423):     at android.graphics.BitmapFactory.decodeFile(BitmapFactory.java:284)
07-25 15:39:38.664: ERROR/AndroidRuntime(31423):     at android.graphics.BitmapFactory.decodeFile(BitmapFactory.java:309)
07-25 15:39:38.664: ERROR/AndroidRuntime(31423):     at com.rodasys.profile.myBackgroundUploader.uploadImage(myBackgroundUploader.java:133)
07-25 15:39:38.664: ERROR/AndroidRuntime(31423):     at com.rodasys.profile.myBackgroundUploader.doInBackground(myBackgroundUploader.java:57)
07-25 15:39:38.664: ERROR/AndroidRuntime(31423):     at com.rodasys.profile.myBackgroundUploader.doInBackground(myBackgroundUploader.java:1)

Thanks in Advance

  • 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-24T02:48:22+00:00Added an answer on May 24, 2026 at 2:48 am

    yes imageview is a static fileld. public static ImageView imgView

    It seems that is the problem which causes memory leak and consequently low memory.
    You may want to read this excellent article about how to avoid it: http://www.curious-creature.org/2008/12/18/avoid-memory-leaks-on-android/

    In short: don’t use static instance variable. You should be fine by removing static (if it does not hurt your code’s logic), otherwise you will have to redesign the activity without static field containing ImageView.

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

Sidebar

Related Questions

Hi stackoverflow friends, I need to take a picture using camera and after takin
Dear Friends from Stackoverflow, Please help me with a problem that i'm having when
Hi stackoverflow friends I want to upload text along with image to the webserver.
StackOverflow user jolson had a very nice piece of code that exemplifies how one
Stackoverflow: For a cs assigment I am using the following code to stream audio.
Good Day All, I’m new to programming. I’m using Visual Studio 2010. I’m taking
Hi friends, Am newbie for windows Development .i have created Grid With tabcontrol using
I realize these questions have been asked before on Stackoverflow, but now that FBML
this is my algorithm that I have written it with my friends (which are
Hello my StackOverflow friends. I have been doing wxPython tutorials and reading the documentation,

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.