In Xamarin.Android, are constant strings allocated in Java?

Viewed 28

In Xamarin.Android, if I set the text on a android.widget.TextView to a constant string like this:

var label = new TextView(context);
label.Text = "Hello";  // Does a Java string get allocated here?

does a Java string get allocated at runtime and "Hello" gets stored in it?

The 2nd question: If a Java string gets allocated, is there a way to avoid the extra allocation?

Here's what I mean by "extra": If you compare it to C#, in C# a constant (literal) string interned, it becomes a part of the intern pool, it only gets allocated once when app is started. Is there a similar mechanism in Xamarin.Android ?

0 Answers
Related