aspnet / Hosting

[Archived] Code for hosting and starting up an ASP.NET Core application. Project moved to https://github.com/aspnet/Extensions and https://github.com/aspnet/AspNetCore
Apache License 2.0
552 stars 312 forks source link

Dereference the HttpContext when it's no longer needed #1552

Closed davidfowl closed 5 years ago

davidfowl commented 5 years ago
davidfowl commented 5 years ago

Why bother? The HttpContext and the RequestServicesFeature have almost exactly the same lifetime.

I was looking at dumps and noticed this. What's interesting is that when looking at the dump (when using kestrel), it is stored per connection. Even though it does get cleared out between, it looks pretty weird. It also doesn't hurt, but you're right we do have a bunch of features other features that are in the same boat.

Are you going to clear the _scopeFactory while you're at it?

Yes, I should

Tratcher commented 5 years ago

Kestrel keeps a field for the IServiceProvidersFeature per http/1 connection, but it clears it at the start/end of every request.

davidfowl commented 5 years ago

Yes thats what I said 😄