it won't fix your problem, but if you move past this use linkedlist to store your weakreferences! That's how microsoft does it. Anyway I'll stop harping about it...
On Wed, Aug 29, 2012 at 6:12 PM, AlexeySb <alexe...@gmail.com> wrote: > Hi, > > As fast and temporary solution I made a derived class from WeakReference > with extended get_Target behaviour. It uses JNI to check the reference. It > is not a "silver bullet", because this is only a workaround, as an > example, it may be possible that Dalvik already allocated another > object with the same address, so be ready for some kind of InvalidCast > exception in this case. So i desided to follow next two rules: > 1. avoid use of WeakReferences with peer objects. > 2. write cache for java objects using java. > > My temporary solution below: > > namespace Android.Workarounds > { > using Android.Runtime; > public class WeakReferenceWorkaround : System.WeakReference > { > public WeakReferenceWorkaround(object target) : base(target) > { > } > public WeakReferenceWorkaround(object target, bool trackResurrection) : > base(target, trackResurrection) > { > } > public override object Target > { > get > { > var target = base.Target; > if (target != null) > { > var javaObject = target as IJavaObject; > if (javaObject != null) > { > var javaLocalRef = JNIEnv.ToLocalJniHandle(javaObject); > if (javaLocalRef == null || javaLocalRef == IntPtr.Zero) > return null; > JNIEnv.DeleteLocalRef(javaLocalRef); > } > } > return target; > } > } > } > } > > I just added next lines before cache implementation. > #if __ANDROID__ > using WeakReference = Android.Workarounds.WeakReferenceWorkaround; > #endif > > Regards > 2012/8/29 bjarke [via Mono for Android] <[hidden > email]<http://user/SendEmail.jtp?type=node&node=5711651&i=0> > > > >> Hi, >> >> Thank you for the response. Lets hope they get it fixed fairly quickly. >> Do you use any alternative way of caching images while waiting? >> >> Regards >> >> ------------------------------ >> If you reply to this email, your message will be added to the >> discussion below: >> >> http://mono-for-android.1047100.n5.nabble.com/Image-caching-tp5710451p5711618.html >> To unsubscribe from Image caching, click here. >> NAML<http://mono-for-android.1047100.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml> >> > > > ------------------------------ > View this message in context: Re: Image > caching<http://mono-for-android.1047100.n5.nabble.com/Image-caching-tp5710451p5711651.html> > > Sent from the Mono for Android mailing list > archive<http://mono-for-android.1047100.n5.nabble.com/>at Nabble.com. > > _______________________________________________ > Monodroid mailing list > Monodroid@lists.ximian.com > > UNSUBSCRIBE INFORMATION: > http://lists.ximian.com/mailman/listinfo/monodroid > > -- Extreme Knowledge is not something for which he programs a computer but for which his computer is programming him. -Wozniak - if my programming advice has helped you, feel free to donate to : <https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=KYUXV2PG88YQQ> <https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=KYUXV2PG88YQQ> <https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=KYUXV2PG88YQQ>
_______________________________________________ Monodroid mailing list Monodroid@lists.ximian.com UNSUBSCRIBE INFORMATION: http://lists.ximian.com/mailman/listinfo/monodroid