Out of Memory issue when uploading large files
See original GitHub issueWhen we are uploading the large files with RestSharp, we randomly get some OutOfMemory issues. This happens because RestSharp is using HttpWebRequest behind the scene, and the default value for AllowWriteStreamBuffering is true. This mean that the whole file are loaded in memory when doing the query, in case there are some redirections to be able to replay it. But If we are uploading a 500 mb file, its an issue.
What we would need is to be able to set the AllowWriteStreamBuffering to false, but there is no way right now to alter the AllowWriteStreamBuffering in the ConfigureWebRequest.
Something like this would be sufficient for our need:
var request = new RestRequest(Method.POST); request.AllowWriteStreamBuffering = false; request.Files.Add(new FileParameter // ...
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (3 by maintainers)
I encounter same issue and don’t how to deal with
As @yvesmh rightfully mentioned in #1213, this issue can be solved by disabling the
WebRequest
write stream buffering. You can use the web request configuration onIRestClient
to handle such cases.client.ConfigureWebRequest(x => x.AllowWriteStreamBuffering = false);