Я получаю OutOfMemoryError, когда беру больше 13 снимков.и после перезапуска происходит сбой, это позволяет мне сделать еще 13 снимков
Я перезапускаю приложение после сбоя.
Здесь My StactTrace
PID: 9656
java.lang.OutOfMemoryError: (Heap Size=259476KB, Allocated=246686KB)
at android.graphics.Bitmap.nativeCreate(Native Method)
at android.graphics.Bitmap.createBitmap(Bitmap.java:1137)
at android.graphics.Bitmap.createBitmap(Bitmap.java:1109)
at android.graphics.Bitmap.createBitmap(Bitmap.java:1076)
at
com.redmonk.bricapp.enterprise.cameramodule.control.CameraPreview.
initFocusDrawingTools(CameraPreview.java:114)
at
com.redmonk.bricapp.enterprise.cameramodule.control.CameraPreview.
surfaceChanged(CameraPreview.java:139)
at android.view.SurfaceView.updateWindow(SurfaceView.java:583)
at android.view.SurfaceView.access$000(SurfaceView.java:86)
at android.view.SurfaceView$3.onPreDraw(SurfaceView.java:175)
at
android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:847)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1993)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1076)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5905)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:807)
at android.view.Choreographer.doCallbacks(Choreographer.java:601)
at android.view.Choreographer.doFrame(Choreographer.java:562)
at
android.view.Choreographer$FrameDisplayEventReceiver.run
(Choreographer.java:791
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5633)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run
(ZygoteInit.java:896)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:712)
at dalvik.system.NativeStart.main(Native Method)
Метод, при котором яПолучаю исключение Я перезагружаю приложение после сбоя
private void focused() {
focusing = false;
String checkBeep = Prefs.getString("BeepDone","");
try {
if (!checkBeep.equals("true")) {
MediaPlayer mPlayer2, mMediaPlayer;
mMediaPlayer = new MediaPlayer();
mMediaPlayer =
MediaPlayer.create(WebServiceSingleTon.getInstance().mainActivity,R.raw.
beepnew);
mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
mMediaPlayer.setVolume(1, 1);
mMediaPlayer.setLooping(false);
mMediaPlayer.start();
Prefs.putString("BeepDone", "true");
}
if (focusCallback != null) {
focusCallback.onFocused(camera);
}
}catch (OutOfMemoryError e)
{
e.printStackTrace();
cp.initiateSmoothRestart();// I am restarting app Here
}catch (Exception e)
{
e.printStackTrace();
}
}
Настройки Gradle для всего проекта.
# IDE (e.g. Android Studio) users:
# Default value: -Xmx10248m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -
XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
# org.gradle.parallel=true
android.useDeprecatedNdk=true