Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CancellationTokenSource of ServerStreaming causes Memory leaking #55

Closed
NeverMorewd opened this issue Nov 17, 2023 · 3 comments
Closed

Comments

@NeverMorewd
Copy link
Contributor

image

image

@NeverMorewd
Copy link
Contributor Author

NeverMorewd commented Nov 17, 2023

It seems that the cts from CreateLinkedTokenSource() need to be dispose manually.
I has apply the workaround with adding using in front of var combined in MessageReader.cs

public async Task<bool> MoveNext(CancellationToken cancellationToken)
{
    try
    {
            using var combined =
            CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, _callCancellationToken,
                _deadline.Token);
        return await _payloadQueue.MoveNext(combined.Token).ConfigureAwait(false);
    }
    catch (OperationCanceledException)
    {
        if (_deadline.IsExpired)
        {
            throw new RpcException(new Status(StatusCode.DeadlineExceeded, ""));
        }
        else
        {
            throw new RpcException(Status.DefaultCancelled);
        }
    }
}

@NeverMorewd
Copy link
Contributor Author

refer: dotnet/runtime#78180

@cyanfish
Copy link
Owner

Thanks, #56 merged and included in 3.0.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants