Skip to content

Avoid allocation in object construction by reflection #12832

@Yves57

Description

@Yves57

During an analysis about memory allocations in an ASP.NET Core service (github/dotnet/extensions#693), I have found that there is maybe an optimization in (at least) object construction by reflection.
When constructing an object by reflection, the method MethodBase.CheckArguments() seems to duplicate the parameters (copyOfParameters) because they may be changed by CheckValue(). But this method seems to just return the value as-is in the normal cases. So isn't it possible to do a "lazy allocation" only if necessary?

/cc @pakrym

Metadata

Metadata

Type

No type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions