I use the camera in my android app and I hold my phone in portrait mode (the cameraView is in Landscape, that’s the first thing strange) and when I turn my phone to have it in landscape mode, I get errors.
VM won't let us allocate ... bytes
The error line showed is
setContentView(R.layout.gameactivity);
This post is interesting Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
Yet I use no bitmaps in my activity so I don’t know why I get erros about Bitmaps
02-01 10:07:30.301: E/AndroidRuntime(5715): Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
02-01 10:07:30.301: E/AndroidRuntime(5715): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
02-01 10:07:30.301: E/AndroidRuntime(5715): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:460)
02-01 10:07:30.301: E/AndroidRuntime(5715): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:336)
02-01 10:07:30.301: E/AndroidRuntime(5715): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:697)
02-01 10:07:30.301: E/AndroidRuntime(5715): at android.content.res.Resources.loadDrawable(Resources.java:1709)
02-01 10:07:30.301: E/AndroidRuntime(5715): at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
02-01 10:07:30.301: E/AndroidRuntime(5715): at android.widget.ImageView.<init>(ImageView.java:118)
02-01 10:07:30.301: E/AndroidRuntime(5715): at android.widget.ImageView.<init>(ImageView.java:108)
02-01 10:07:30.301: E/AndroidRuntime(5715): ... 27 more
You got a memory leak.
When the device changes the layout the Activity will be created again. Most likely you got for example some huge static variables etc. that won’t get released.
Maybe adding “onConfigChanged:orientation” Tag to your Activity in Manifest helps you to prevent the memory leak, but it’s not a good solution for every case.
There are also several sites that show you how to find the memory leaks, like this