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

[Foundation] Set the MaxInputInMemory to match the limit from other BCL classes. Fixes #21537 #21660

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mandel-macaque
Copy link
Member

The MaxInputInMemory property is set by default to be long.MaxValue. This value is much larger than the one we can find in other BCL classes such as the HttpContent max value and the MemoryStream max value.

It is important to notice that the HttpContent.MaxValue is used to limit the value of the MaxResponseContentBufferSize property in the HttpClient. This means that by making this move we are following the rest of the BCL.

Fixes #21537

…CL classes. Fixes #21537

The MaxInputInMemory property is set by default to be long.MaxValue.
This value is much larger than the one we can find in other BCL classes
such as the HttpContent [max value](https://github.com/microsoft/referencesource/blob/master/System/net/System/Net/Http/HttpContent.cs#L20)
and the MemoryStream [max value](https://github.com/dotnet/runtime/blob/1d1bf92fcf43aa6981804dc53c5174445069c9e4/src/libraries/System.Private.CoreLib/src/System/IO/MemoryStream.cs#L37).

It is important to notice that the HttpContent.MaxValue is used to
limit the value of the MaxResponseContentBufferSize property in the
HttpClient. This means that by making this move we are following the
rest of the BCL.

Fixes #21537
@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build] Windows Integration Tests passed 💻

All Windows Integration Tests passed.

Pipeline on Agent
Hash: 10aa1d9927898beb8a37e300d59c477900a22a22 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ API diff for current PR / commit

.NET (No breaking changes)

✅ API diff vs stable

.NET (No breaking changes)

ℹ️ Generator diff

Generator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes)

Pipeline on Agent
Hash: 10aa1d9927898beb8a37e300d59c477900a22a22 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build] Tests on macOS M1 - Mac Monterey (12) passed 💻

All tests on macOS M1 - Mac Monterey (12) passed.

Pipeline on Agent
Hash: 10aa1d9927898beb8a37e300d59c477900a22a22 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build] Tests on macOS X64 - Mac Sonoma (14) passed 💻

All tests on macOS X64 - Mac Sonoma (14) passed.

Pipeline on Agent
Hash: 10aa1d9927898beb8a37e300d59c477900a22a22 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build] Tests on macOS M1 - Mac Ventura (13) passed 💻

All tests on macOS M1 - Mac Ventura (13) passed.

Pipeline on Agent
Hash: 10aa1d9927898beb8a37e300d59c477900a22a22 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

🚀 [CI Build] Test results 🚀

Test results

✅ All tests passed on VSTS: test results.

🎉 All 103 tests passed 🎉

Tests counts

✅ cecil: All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (iOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (MacCatalyst): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (macOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (Multiple platforms): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (tvOS): All 1 tests passed. Html Report (VSDrops) Download
✅ framework: All 2 tests passed. Html Report (VSDrops) Download
✅ fsharp: All 4 tests passed. Html Report (VSDrops) Download
✅ generator: All 3 tests passed. Html Report (VSDrops) Download
✅ interdependent-binding-projects: All 4 tests passed. Html Report (VSDrops) Download
✅ introspection: All 4 tests passed. Html Report (VSDrops) Download
✅ linker: All 40 tests passed. Html Report (VSDrops) Download
✅ monotouch (iOS): All 7 tests passed. Html Report (VSDrops) Download
✅ monotouch (MacCatalyst): All 8 tests passed. Html Report (VSDrops) Download
✅ monotouch (macOS): All 9 tests passed. Html Report (VSDrops) Download
✅ monotouch (tvOS): All 9 tests passed. Html Report (VSDrops) Download
✅ msbuild: All 2 tests passed. Html Report (VSDrops) Download
✅ xcframework: All 4 tests passed. Html Report (VSDrops) Download
✅ xtro: All 1 tests passed. Html Report (VSDrops) Download

Pipeline on Agent
Hash: 10aa1d9927898beb8a37e300d59c477900a22a22 [PR build]

Copy link
Member

@rolfbjarne rolfbjarne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I don't have any problems with this change, I'm not sure it's fixing the user's problem: files smaller than 2gb will still be cached in memory, and that's a rather big chunk of memory.

What about just not caching (or make it opt-in), by deleting this?

if (length.HasValue && (length <= MaxInputInMemory))
nsrequest.Body = NSData.FromStream (stream);
else

It might be necessary to make it opt-in though, iirc there might be some differences wrt the Content-Length header when caching or no caching (can't compute Content-Length unless the data to send is cached).

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

Successfully merging this pull request may close these issues.

Upload Progress with ProgressMessageHandler Completes Unexpectedly
6 participants