在.net 4.5中,CLR小組有很多改變StringBuilder
類。 Here是StringBuilder
類的代碼參考。在這裏我們可以找到MaxChunkSize
等於8000和上述這個區域註釋:.net 4.5中的StringBuilder是否具有大於MaxChunkSize的塊大小
// We want to keep chunk arrays out of large object heap (< 85K bytes ~ 40K chars) to be sure.
// Making the maximum chunk size big means less allocation code called, but also more waste
// in unused characters and slower inserts/replaces (since you do need to slide characters over
// within a buffer).
所以我仍然不知道,如果我們將與StringBuilder
工作追加大的字符串,例如:
var sb = new StringBuilder();
sb.Append(<<Here comes the string with length larger than 80 000 symbols>>);
我們還會在LargeObjectHeap中分配ChunksArrays嗎?