This repository has been archived by the owner on Dec 14, 2018. It is now read-only.
Waste less memory when model binding #5499
Comments
I don't believe you that the fix with |
@rynowak agreed. I said that one was (at least) "a bit more complicated". Would likely require special-casing that strategy class or (somehow) reducing the size of its |
Let's do the simple change for avoiding enumerator allocations. Let's not do the rest of the change, as it is unlikely to simple, and the benefits are small. |
dougbu
added a commit
that referenced
this issue
Nov 25, 2016
- #5499 - switch `foreach` to `for` and use less Linq when accessing `modelMetadata.Properties`
dougbu
added a commit
that referenced
this issue
Dec 6, 2016
- #5499 - switch `foreach` to `for` and use less Linq when accessing `modelMetadata.Properties`
dougbu
added a commit
that referenced
this issue
Dec 6, 2016
- #5499 - switch `foreach` to `for` and use less Linq when accessing `modelMetadata.Properties` - change backing field for `ModelExplorer.Properties` from a list to an array
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Loops through
ModelMetadata.Properties
inComplexTypeModelBinder
eat 1.3% of the total memory used in the BigModelBinding scenario. Boxing theList<ModelMetadata>
Enumerator
s could be completely avoided by switching fromforeach
tofor
(twice) in this class.Similarly, enumerating children of the
DefaultComplexObjectValidationStrategy
eats about 0.8% of the total used in the same scenario. The fix here is a bit more complicated because thatEnumerator
class is not currently exposed. Still, it could be exposed and made into astruct
because everything's in anInternal
namespace.BigModelBinding
Exercises
HomeController.Index()
view using./loadtest.ps1
. Binds an instance of theModel
using form data from./postdata.txt
.Excess
Enumerator
sThe text was updated successfully, but these errors were encountered: