From https://github.com/dotnet/corefx/blob/master/Documentation/coding-guidelines/interop-pinvokes.md#strings
StringBuilder marshalling always re-allocate/re-copy buffers. Make sense review our code to reduce such allocations.
From @daxian-dbw #9066 (comment)
it seems StringBuilder should never be used for P/Invoke as it incurs 4 allocations. I think it make sense to review our uses of it and replace with ArrayPool when appropriate, because we will copy the existing pattern when writing new code.
From above docs:
[USE] Char arrays from ArrayPool or StringBuffer.
From https://github.com/dotnet/corefx/blob/master/Documentation/coding-guidelines/interop-pinvokes.md#strings
From @daxian-dbw #9066 (comment)
From above docs: