Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report for Bug 38479 on
Developer Community or GitHub if you have new
information to add and do not yet see a matching new report.
If the latest results still closely match this report, you can use the
In special cases on GitHub you might also want the comments:
GitHub Markdown with public comments
Created attachment 14908 [details]
I noticed that default Xamarin implementation creates and release new Java.Lang.String on every text change, can be replaced with direct method call:
public string Text
if (this.TextFormatted == null)
return (string) null;
Java.Lang.String @string = value != null ? new Java.Lang.String(value) : (Java.Lang.String) null;
this.TextFormatted = (ICharSequence) @string;
if (@string == null)
You can reduce the amount of memory allocation for strings by replacing it at a direct method call:
if (TextView.id_setText_Ljava_lang_CharSequence_ == IntPtr.Zero)
TextView.id_setText_Ljava_lang_CharSequence_ = JNIEnv.GetMethodID(TextView.class_ref, "setText", "(Ljava/lang/CharSequence;)V");
IntPtr jobject = JNIEnv.NewString(value); //Instead of create String wrapper using direct handle
JValue* parms = stackalloc JValue;
*parms = new JValue(jobject);
JNIEnv.CallVoidMethod(this.Handle, TextView.id_setText_Ljava_lang_CharSequence_, parms);
I think you can improve not only setter but also the getter but it will be a little harder because you need to call ToString method on ICharSequence handle.
I tested it on my device performance has grown by 5 times.
I added project with performance test.
Has anyone looked into this yet? I would love to see some more performance data on this considering the discrepancies between android the the other platforms in performance.