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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:54:23+00:00 2026-06-13T02:54:23+00:00

I have a memory problem when using camera in my app. I have used

  • 0

I have a memory problem when using camera in my app. I have used SurfaceView for taking picture. After taking the picture in log cat it is showing Heap memory grow to 30 mb sometimes 40mb also. Because of this some times app is crashing also “OutofMemoryException”. Here I am providing my code . Please help me.

surfaceView = (SurfaceView) findViewById(R.id.camerapreview);
surfaceHolder = surfaceView.getHolder();
surfaceHolder.addCallback(this);
surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);


capture.setOnClickListener(new Button.OnClickListener() {
        @Override
        public void onClick(View arg0) {
            camera.takePicture(myShutterCallback, myPictureCallback_RAW,
                    myPictureCallback_JPG);
            capture.setClickable(false);
        }
    });



PictureCallback myPictureCallback_RAW = new PictureCallback() {
    @Override
    public void onPictureTaken(byte[] arg0, Camera arg1) {
        System.out.println("myPictureCallback_RAW");
    }
};




 PictureCallback myPictureCallback_JPG = new PictureCallback() {
    @Override
    public void onPictureTaken(byte[] arg0, Camera arg1) {


        try {

            bitmapPicture = BitmapFactory.decodeByteArray(arg0, 0,
                    arg0.length);

        }
        catch (OutOfMemoryError e) {
                Toast.makeText(FromCamera.this, "Please try again",
                        Toast.LENGTH_SHORT).show();
        }catch (Exception e) {
            Toast.makeText(FromCamera.this, "Please try again",
                    Toast.LENGTH_SHORT).show();
        }

        capture.setEnabled(false);
        buttonBack.setVisibility(View.VISIBLE);
        buttonDone.setVisibility(View.VISIBLE);
        buttonBack.setEnabled(true);
        buttonDone.setEnabled(true);
    }
};



ShutterCallback myShutterCallback = new ShutterCallback() {
    @Override
    public void onShutter() {
        System.out.println("onShutter");
    }
};

I have tried force Garbage Collection, but still no use.

public void surfaceDestroyed(SurfaceHolder holder) {
    if (camera != null) {
        camera.stopPreview();
        camera.release();
        camera = null;
    }
    previewing = false;
}
  • 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-13T02:54:24+00:00Added an answer on June 13, 2026 at 2:54 am

    You should inspect the memory allocations of your app, see a related post here (it also has some great articles linked at the end).

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

Sidebar

Related Questions

I have a corruption memory heap problem with an application. by using windbg and
I have a Problem in my App with the Dirty Memory Size and want
I have a memory leak problem using OData where data retrieved from the OData
I'm using Qt4.6, 32bit compiled under 64bit Linux, and have a puzzling memory problem
I have a problem with a memory leak in a .NET CF application. Using
I am using Delphi XE. I have come across a memory leak problem using
We have a memory overwrite problem. At some point, during the course of our
I have a memory leak from 3 UIImages the problem is I can't just
I have a problem with a memory leak. I have this code in a
I have a problem with a memory leak in a very large ASP.NET application.

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.