Skip to content

Consider pooling buffer within StringBuilder #19553

@AlexRadch

Description

@AlexRadch

Some issues request string builders with less memory allocations. See dotnet/corefx#13875 (comment) and https://github.com/dotnet/corefx/issues/13893
I suggest rewrite StringBuilder to use ArrayPool internal and also add next API to StringBuilder

public class StringBuilder
{

    public string ToStringAndRelease(); // return result String and release buffers to ArrayPool 
    public string ToStringAndRelease(int index, int count); // return result String and release buffers to ArrayPool
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-System.CollectionsenhancementProduct code improvement that does NOT require public API changes/additions

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions