java.lang.OutOfMemoryError.printStackTrace()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(6.2k)|赞(0)|评价(0)|浏览(281)

本文整理了Java中java.lang.OutOfMemoryError.printStackTrace()方法的一些代码示例,展示了OutOfMemoryError.printStackTrace()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。OutOfMemoryError.printStackTrace()方法的具体详情如下:
包路径:java.lang.OutOfMemoryError
类名称:OutOfMemoryError
方法名:printStackTrace

OutOfMemoryError.printStackTrace介绍

暂无

代码示例

代码示例来源:origin: spotbugs/spotbugs

public void tricky() {
  try {
    System.out.println("tricky()");
  } catch (OutOfMemoryError e) {
    e.printStackTrace();
  }
  System.gc();
}

代码示例来源:origin: stanfordnlp/CoreNLP

public void nudgeDownArraySize() {
 try {
  if (arraySize > 2) {
   considerCreatingArrays(arraySize - 2);
  }
 } catch (OutOfMemoryError oome) {
  oome.printStackTrace();
 }
}

代码示例来源:origin: spotbugs/spotbugs

public void tricky2() {
  try {
    System.out.println("tricky()");
  } catch (OutOfMemoryError e) {
    e.printStackTrace();
  }
  for (int i = 0; i < 20; i++)
    System.out.println(i);
  System.gc();
}

代码示例来源:origin: tyrantgit/ExplosionField

public static Bitmap createBitmapSafely(int width, int height, Bitmap.Config config, int retryCount) {
    try {
      return Bitmap.createBitmap(width, height, config);
    } catch (OutOfMemoryError e) {
      e.printStackTrace();
      if (retryCount > 0) {
        System.gc();
        return createBitmapSafely(width, height, config, retryCount - 1);
      }
      return null;
    }
  }
}

代码示例来源:origin: JessYanCoding/MVPArms

/**
 * 将图片按照某个角度进行旋转
 *
 * @param bm     需要旋转的图片
 * @param degree 旋转角度
 * @return 旋转后的图片
 */
public static Bitmap rotateBitmapByDegree(Bitmap bm, int degree) {
  Bitmap returnBm = null;
  // 根据旋转角度,生成旋转矩阵
  Matrix matrix = new Matrix();
  matrix.postRotate(degree);
  try {
    // 将原始图片按照旋转矩阵进行旋转,并得到新的图片
    returnBm = Bitmap.createBitmap(bm, 0, 0, bm.getWidth(), bm.getHeight(), matrix, true);
  } catch (OutOfMemoryError e) {
    e.printStackTrace();
  }
  if (returnBm == null) {
    returnBm = bm;
  }
  if (bm != returnBm) {
    bm.recycle();
  }
  return returnBm;
}

代码示例来源:origin: LuckyJayce/LargeImage

@Override
protected void doInBackground() {
  BitmapFactory.Options decodingOptions = new BitmapFactory.Options();
  decodingOptions.inSampleSize = scale;
  try {
    bitmap = decoder.decodeRegion(new Rect(0, 0, imageWidth, imageHeight),
        decodingOptions);
  } catch (OutOfMemoryError e) {
    e.printStackTrace();
    throwable = e;
  } catch (Exception e) {
    e.printStackTrace();
    throwable = e;
  }
}

代码示例来源:origin: GitLqr/LQRWeChat

/**
 * 根据一个网络连接(String)获取bitmap图像
 *
 * @param imageUri
 * @return
 */
public static Bitmap getNetBitmap(String imageUri) {
  // 显示网络上的图片
  Bitmap bitmap = null;
  try {
    URL myFileUrl = new URL(imageUri);
    HttpURLConnection conn = (HttpURLConnection) myFileUrl
        .openConnection();
    conn.setDoInput(true);
    conn.connect();
    InputStream is = conn.getInputStream();
    bitmap = BitmapFactory.decodeStream(is);
    is.close();
  } catch (OutOfMemoryError e) {
    e.printStackTrace();
    bitmap = null;
  } catch (IOException e) {
    e.printStackTrace();
    bitmap = null;
  }
  return bitmap;
}

代码示例来源:origin: jeasonlzy/ImagePicker

/**
   * @param bitmap  要旋转的图片
   * @param degrees 选择的角度(单位 度)
   * @return 旋转后的Bitmap
   */
  public Bitmap rotate(Bitmap bitmap, int degrees) {
    if (degrees != 0 && bitmap != null) {
      Matrix matrix = new Matrix();
      matrix.setRotate(degrees, (float) bitmap.getWidth() / 2, (float) bitmap.getHeight() / 2);
      try {
        Bitmap rotateBitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
        if (bitmap != rotateBitmap) {
//                    bitmap.recycle();
          return rotateBitmap;
        }
      } catch (OutOfMemoryError ex) {
        ex.printStackTrace();
      }
    }
    return bitmap;
  }

代码示例来源:origin: qiujuer/Genius-Android

private void load() {
  try {
    // Find Bitmap
    mSrc = BitmapFactory.decodeResource(getResources(), R.mipmap.wallpaper);
    mView.setImageBitmap(mSrc);
  } catch (OutOfMemoryError error) {
    error.printStackTrace();
    finish();
  }
}

代码示例来源:origin: jeasonlzy/ImagePicker

e.printStackTrace();

代码示例来源:origin: crazycodeboy/TakePhoto

/**
 * 纠正照片的旋转角度
 *
 * @param path
 */
public void correctImage(Context context, Uri path) {
  String imagePath = TUriParse.parseOwnUri(context, path);
  int degree;
  if ((degree = getBitmapDegree(imagePath)) != 0) {
    Bitmap bitmap = BitmapFactory.decodeFile(imagePath);
    if (bitmap == null) {
      return;
    }
    Bitmap resultBitmap = rotateBitmapByDegree(bitmap, degree);
    if (resultBitmap == null) {
      return;
    }
    try {
      resultBitmap.compress(Bitmap.CompressFormat.JPEG, 100, new FileOutputStream(new File(imagePath)));
    } catch (FileNotFoundException e) {
      e.printStackTrace();
    } catch (OutOfMemoryError e) {
      e.printStackTrace();
    }
  }
}

代码示例来源:origin: igreenwood/SimpleCropView

@Override public void run() {
  final int exifRotation = Utils.getExifOrientation(context, uri);
  int maxSize = Utils.getMaxSize();
  int requestSize = Math.min(width, maxSize);
  try {
   final Bitmap sampledBitmap = Utils.decodeSampledBitmapFromUri(context, uri, requestSize);
   mHandler.post(new Runnable() {
    @Override public void run() {
     imageView.setImageMatrix(Utils.getMatrixFromExifOrientation(exifRotation));
     imageView.setImageBitmap(sampledBitmap);
    }
   });
  } catch (OutOfMemoryError e) {
   e.printStackTrace();
  } catch (Exception e) {
   e.printStackTrace();
  }
 }
}

代码示例来源:origin: wangdan/AisenWeiBo

@Override
public String workInBackground(Void... params) throws TaskException {
  try {
    Bitmap bitmap = BitmapDecoder.decodeSampledBitmapFromFile(path, SystemUtils.getScreenHeight(WeiboClientActivity.this), SystemUtils.getScreenHeight(WeiboClientActivity.this));
    bitmap = BitmapUtil.rotateBitmap(bitmap, 90);
    ByteArrayOutputStream outArray = new ByteArrayOutputStream();
    bitmap.compress(Bitmap.CompressFormat.JPEG, 100, outArray);
    FileUtils.writeFile(new File(path), outArray.toByteArray());
  } catch (OutOfMemoryError e) {
    e.printStackTrace();
  }
  return path;
}

代码示例来源:origin: LuckyJayce/LargeImage

e.printStackTrace();
  throwable = e;
} catch (Exception e) {

代码示例来源:origin: wangdan/AisenWeiBo

@Override
public String workInBackground(Void... params) throws TaskException {
  try {
    Bitmap bitmap = BitmapDecoder.decodeSampledBitmapFromFile(path, SystemUtils.getScreenHeight(getActivity()), SystemUtils.getScreenHeight(getActivity()));
    bitmap = BitmapUtil.rotateBitmap(bitmap, 90);
    
    ByteArrayOutputStream outArray = new ByteArrayOutputStream();
    bitmap.compress(CompressFormat.JPEG, 100, outArray);
    
    FileUtils.writeFile(new File(path), outArray.toByteArray());
  } catch (OutOfMemoryError e) {
    e.printStackTrace();
  }
  return path;
}

代码示例来源:origin: bingoogolapple/BGABanner-Android

exception.printStackTrace();
  result = new LoadBitmapPair(null, exception);
} catch (Exception exception) {

代码示例来源:origin: jiangqqlmj/FastDev4Android

return null;
} catch (OutOfMemoryError e) {
  e.printStackTrace();
  return null;
} finally {

代码示例来源:origin: jiangqqlmj/FastDev4Android

e.printStackTrace();
if (requestCallBack != null) {
  requestCallBack.onRequestError(

代码示例来源:origin: stanfordnlp/CoreNLP

return true;
} catch (OutOfMemoryError oome) {
 oome.printStackTrace();
 parseNoMemory = true;
 pparser.nudgeDownArraySize();

代码示例来源:origin: pentaho/pentaho-kettle

e.printStackTrace();
} finally {
 step.setErrors( 1 );

相关文章