November 2019
Intermediate to advanced
404 pages
12h 9m
English
If JIT compilation is causing a runtime performance loss, be aware that it is actually possible to force JIT compilation of a method at any time via reflection. Reflection is a useful feature of the C# language that allows our code base to explore itself introspectively for type information, methods, values, and metadata. Using reflection is often a very costly process. It should be avoided at runtime or, at the very least, only used during initialization or other loading times. Not doing so can easily cause significant CPU spikes and gameplay freezing.
We can manually force JIT compilation of a method using reflection to obtain a function pointer to it:
var method = typeof(MyComponent).GetMethod("MethodName");if (method ...Read now
Unlock full access