I've read the "Take a Picture and Save Using Camera App" example and
downloaded provided sample (
http://docs.xamarin.com/recipes/android/other_ux/camera_intent/take_a_picture_and_save_using_camera_app
).

However it looks the sample is either too inefficient or there is a mono's
issue - just after one picture grab it grows heap by 30M and almost
exhausts available memory on Samsung Galaxy S2. Attempting showing a 2nd
picture crashes and burns the app with Java.Lang.OutOfMemoryError.
I find it especially curious given that the size of the picture taken is
mere 2-3M in size.

Here's the application output:

*GREF GC Threshold: 46800*
*Grow heap (frag case) to 10.842MB for 441776-byte allocation*
*Grow heap (frag case) to 11.791MB for 995296-byte allocationLoaded
assembly: MonoDroidConstructors [External]*
*Loaded assembly: System.Xml.dll [External]*
*
*
*showStatusIcon on inactive InputConnection*
*Grow heap (frag case) to 42.020MB for 31961104-byte allocation      <---
1st picture is taken and saved. The pic is loaded into the ImageView*
*showStatusIcon on inactive InputConnection*
*Forcing collection of SoftReferences for 31961104-byte allocation    *
*Out of memory on a 31961104-byte allocation.
     **<--- attempting to take 2nd picture... BOOM!*
*--- decoder->decode returned false*
*UNHANDLED EXCEPTION: Java.Lang.OutOfMemoryError: Exception of type
'Java.Lang.OutOfMemoryError' was thrown.*
*at Android.Runtime.JNIEnv.CallStaticObjectMethod
(intptr,intptr,Android.Runtime.JValue[]) [0x00024] in
/Users/builder/data/lanes/monodroid-lion-bs1/03814ac5/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:767
*
*at Android.Provider.MediaStore/Images/Media.GetBitmap
(Android.Content.ContentResolver,Android.Net.Uri) [0x0002d] in
/Users/builder/data/lanes/monodroid-lion-bs1/03814ac5/source/monodroid/src/Mono.Android/platforms/android-8/src/generated/Android.Provider.MediaStore.cs:1694
*
*at CameraAppDemo.Activity1.OnActivityResult
(int,Android.App.Result,Android.Content.Intent) [0x0003e] in
d:\Development\CameraAppDemo\CameraAppDemo\Activity1.cs:62*
*at Android.App.Activity.n_OnActivityResult_IILandroid_content_Intent_
(intptr,intptr,int,int,intptr) [0x00013] in
/Users/builder/data/lanes/monodroid-lion-bs1/03814ac5/source/monodroid/src/Mono.Android/platforms/android-8/src/generated/Android.App.Activity.cs:1240
*
*at (wrapper dynamic-method) object.902354c1-f8ff-470e-bc76-1c59e3cbf94e
(intptr,intptr,int,int,intptr) <IL 0x00023, 0x0005b>*
*
*
*  --- End of managed exception stack trace ---*
*java.lang.OutOfMemoryError*
* at android.graphics.BitmapFactory.nativeDecodeStream(Native Method)*
* at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:652)*
* at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:724)*
* at android.provider.MediaStore$Images$Media.getBitmap(MediaStore.java:790)
*
* at cameraappdemo.Activity1.n_onActivityResult(Native Method)*
* at cameraappdemo.Activity1.onActivityResult(Activity1.java:37)*
* at android.app.Activity.dispatchActivityResult(Activity.java:5390)*
* at android.app.ActivityThread.deliverResults(ActivityThread.java:3201)*
* at android.app.ActivityThread.handleSendResult(ActivityThread.java:3248)*
* at android.app.ActivityThread.access$1200(ActivityThread.java:140)*
* at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1285)*
* at android.os.Handler.dispatchMessage(Handler.java:99)*
* at android.os.Looper.loop(Looper.java:137)*
* at android.app.ActivityThread.main(ActivityThread.java:4921)*
* at java.lang.reflect.Method.invokeNative(Native Method)*
* at java.lang.reflect.Method.invoke(Method.java:511)*
* at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1027)
*
* at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794)*
* at dalvik.system.NativeStart.main(Native Method)*
*Stacktrace:*
*
*
*  at Android.Runtime.JNIEnv.CallObjectMethod (intptr,intptr) [0x00000] in
/Users/builder/data/lanes/monodroid-lion-bs1/03814ac5/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:129
*
*  at Java.Lang.Throwable.get_Message () [0x0003e] in
/Users/builder/data/lanes/monodroid-lion-bs1/03814ac5/source/monodroid/src/Mono.Android/platforms/android-8/src/generated/Java.Lang.Throwable.cs:195
*
*  at (wrapper runtime-invoke) <Module>.runtime_invoke_object__this__
(object,intptr,intptr,intptr) <IL 0x00050, 0xffffffff>*



Is it due to sloppiness of the sample code? And if so, how can it be
improved to withstand several picture takes and do so in memory efficient
manner?


Thank you, Igor
_______________________________________________
Monodroid mailing list
[email protected]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid

Reply via email to