On Aug 14, 2012, at 4:09 AM, "Breyer, Christian" <[email protected]> wrote:
> On some devices with certain configuration (OS version/Mono version/target
> API) the app runs for days. However, on some, I get the following exception
> after one to several hours.
> Am I missing a dispose? Could this be a bug within monodroid?
Maybe.
Are you using JNIEnv anywhere within your app? If you're creating object
instances (JNIEnv.NewObject()) or calling methods which return local references
(JNIEnv.GetObjectField(), JNIEnv.CallObjectMethod(),
JNIEnv.CallStaticObjectMethod(), etc.), you must either call
JNIEnv.DeleteLocalRef() to destroy the local reference or pass the value to
e.g. Java.Lang.Object.GetObject<T>(IntPtr, JniHandleOwnership) with
JniHandleOwnership.TransferLocalRef:
https://github.com/xamarin/monodroid-samples/blob/master/SanityTests/Hello.cs#L630
If you're not directly using JNIEnv, then it could possibly be a bug on Mono
for Android. I would appreciate any test case...
As a verification, you can enable lref logging, which will them spam logcat
whenever a local reference is created or destroyed:
adb shell setprop debug.mono.log lref
If you see a constantly increasing lref value, something is going wrong
somewhere.
(Though I have noted that lref logging is flaky, and occasionally gives
negative values... Use as a guideline for now.)
> 08-14 09:19:01.236: D/STATUSBAR-NetworkController(1976):
> onSignalStrengthsChanged signalStrength=SignalStrength: 99 -1 -1 -1 -1 -1 -1
> -1 -1 -1 -1 -1 gsm|lte 3 level=3
> 08-14 09:19:01.696: E/dalvikvm(10409): JNI ERROR (app bug): local reference
> table overflow (max=512)
> 08-14 09:19:01.696: W/dalvikvm(10409): JNI local reference table (0x648a78)
> dump:
> 08-14 09:19:01.696: W/dalvikvm(10409): Last 10 entries (of 512):
> 08-14 09:19:01.696: W/dalvikvm(10409): 511: 0x418d2058
> android.os.Messenger
> 08-14 09:19:01.696: W/dalvikvm(10409): 510: 0x418d2058
> android.os.Messenger
Apparently lots of android.os.Messenger instances are being created and not
destroyed. I would suggest looking through your sources for
"android/os/Messenger" (for JNIEnv use) or looking through the lref logging
output for messages containing Android.OS.Messenger.
Thanks,
- Jon
_______________________________________________
Monodroid mailing list
[email protected]
UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid