Memory allocation documentation for ImmutableDictionary Keys and Values #13927
Labels
area-System.Collections
documentation
Documentation bug or enhancement, does not impact product or test code
help wanted
[up-for-grabs] Good issue for external contributors
Milestone
Background
As described in dotnet/corefx#246 (and previously in dotnet/corefx#147), the
Keys
andValues
properties ofImmutableDictionary<TKey, TValue>
cannot be used without incurring memory allocations on the heap. However, a slight modification of user code provides equivalent behavior without these allocations.With allocations:
Without allocations:
Suggestion
Since updating the
Keys
andValues
properties to eliminate the allocations would be a breaking change (#246), the only recourse is to update the documentation for these properties to describe steps a user can take to avoid allocations if these properties are used heavily within a particular application.Caveat
Care must be taken to ensure that the documentation does not read in a way that suggests the
Keys
andValues
properties should not be used. The properties behave properly and would not be even a measurable source of time spent in the application in nearly all cases. This notice is only meant for users making heavy use of these properties who are also actively working to reduce the memory allocations performed within an especially performance-sensitive section of code.The text was updated successfully, but these errors were encountered: