-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Description
There's been lots of discussion about how to optimize strings for the future including things like supporting utf8 but it would be less of a breaking change let users control the backing memory of a particular string so that the memory can be reused. This would especially be useful in lots of places inside of ASP.NET (headers, connection ids etc), where today it's impossible to control that memory and still use the exchange type we want to use (string). Strings are the last kinds of allocations we can't get rid of today.
Strings are one of the only special major reference (and exchange) types that force you to allocate. They are immutable and allocation is controlled by the runtime. If you need large string, it's going into the LOH. There's no way to pool it since strings are immutable. Allowing this would open up a new set of performance optimizations not possible before, or possible with lots of runtime hackery.