-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Avoid allocation in object construction by reflection #12832
Comments
It is not just because of they may be changed by Having said this, there are ways how to optimize this. It just is not as simple as allocating the array lazily. |
Got it! |
I do not think a new flag is necessary. It should be possible to optimize this for everybody without compromising type safety and security characteristics provided by the current implementation. |
I hope this optimization will be developped! I want to see what kind of trick can avoid this allocation! 😃 |
Could change |
Moving to future |
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 byCheckValue()
. 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
The text was updated successfully, but these errors were encountered: