title: Issue during bitmap compression and saving in async task
body: <p>I am writing an app with custom camera facility. In my custom camera after capturing i am drawing the captured image to canvas and providing free hand drawing over that captured imgae and then save option. At the time of saving i am save it as two images which means the one which contains free hand drawing and another one which contains no drawing. Saving is done by writing output stream and compressing bitmaps. The saving and compression of bitmaps done in two separate async tasks. The issue is that  i can capture image up to 16 or 17 times but after that capturing and editing then pressing save button i am getting the exception "vm aborting Fatal signal 11 (SIGSEGV) at 0xdeadd00d (code=1)" .
  Async Task one</p>
  
  <pre><code>public class SaveOriginalImage extends AsyncTask&lt;String, Void, String&gt; {
      OutputStream dataOutputStream;
      Bitmap bitMapOriginalImage;
      String fileName;
      Activity activityContext;
      ProgressDialog progressDialog;
      String sbCaption;
      String fileType;
  
      public SaveOriginalImage(Bitmap bitMap, String filePath,
              Activity currentActivity, String fileCaption) {
          this.bitMapOriginalImage = bitMap;
          this.fileName = filePath;
          this.activityContext = currentActivity;
          this.sbCaption = fileCaption;
      }
  
      @Override
      protected String doInBackground(String... params) {
          try {
              dataOutputStream = new FileOutputStream(fileName);
  
              bitMapOriginalImage
                      .compress(CompressFormat.PNG, 100, dataOutputStream);
              Collection.lastImageFilePath = fileName;
  
              dataOutputStream.flush();
              dataOutputStream.close();
          } catch (FileNotFoundException e) {
              e.printStackTrace();
          } catch (IOException e) {
              e.printStackTrace();
          }
          return null;
      }
  
      @Override
      protected void onPreExecute() {
  
          super.onPreExecute();
  
      }
  
      @Override
      protected void onPostExecute(String result) {
          if (bitMapOriginalImage != null) {
              bitMapOriginalImage.recycle();
              bitMapOriginalImage = null;
          }
      }
  }
  </code></pre>
  
  <p>Async Task 2</p>
  
  <pre><code>public class SaveFreeHandImage extends AsyncTask&lt;String, Void, String&gt; {
  OutputStream dataOutputStream;
  Bitmap bitMapToSave;
  String fileName;
  Activity activityContext;
  ProgressDialog progressDialog;
  String sbCaption;
  String className;
  String fileType;
  
  public SaveFreeHandImage(Bitmap bitMap, String filePath,
          Activity currentActivity, String fileCaption, String className) {
      this.bitMapToSave = bitMap;
      this.fileName = filePath;
      this.activityContext = currentActivity;
      this.sbCaption = fileCaption;
      this.className = className;
  }
  
  @Override
  protected String doInBackground(String... params) {
      try {
  
          dataOutputStream = new FileOutputStream(fileName);
  
          bitMapToSave.compress(CompressFormat.PNG, 100, dataOutputStream);
          Collection.lastImageFilePath = fileName;
          try {
              dataOutputStream.flush();
              dataOutputStream.close();
  
              }
          } catch (IOException e) {
              e.printStackTrace();
          }
  
      } catch (Exception e) {
          e.printStackTrace();
      }
  
      return null;
  }
  
  @Override
  protected void onPostExecute(String result) {
      // super.onPostExecute(result);
      progressDialog.dismiss();
  
      HomeFinal.showCustomToast("Drawing saved to SD card ", 0, 0,
              activityContext);
      Collection.isNewImageAdded = false;
      DrawingView.colorD = Color.parseColor("#000000");
      if (DrawingView.paths != null) {
          if (DrawingView.paths.size() &gt;= 1) {
              DrawingView.paths.clear();
          }
      }
  
      if (bitMapToSave != null) {
          if (!bitMapToSave.isRecycled()) {
              bitMapToSave.recycle();
              bitMapToSave = null;
          }
      }
  }
  
  @Override
  protected void onPreExecute() {
      super.onPreExecute();
      progressDialog = ProgressDialog.show(activityContext, "", "Saving..");
      }
   }
  </code></pre>
  
  <p>I am testing on lenovo a-300h 7 inch tablet . Please give me solution. Thanks in advance.</p>