In C#, when executing ClientContext.ExecuteQuery(), if the query sent to SharePoint has a size above 2MB, it returns an error like this:
The request message is too big. The server does not allow messages larger than 2,097,152 bytes
I have seen this issue is usually found when uploading files. However, in my case this is just a big query that is updating a great quantity of document fields in SharePoint, so no file is involved, just a big list of updated properties, enough to surpass the 2MB limit.
There is also another solution from 2017 where a garbage collector is used. However, after the first measure, subsequent calls return negative values (for some reason initial total memory is bigger that the final total memory).
Is there a way to find out which is the current size of the pending request in the ClientContext, in order to send the buffered request when it reaches a defined limit? (for example 1 MB)