What is the effect of the "Suppress JIT optimization on module load"
debugging option?
I have recently had to turn it off to deal to be able to successfully debug an app that uses a COM component.
What do I risk by turning it off?
You set the Optimize option from Build properties page for your project in Visual Studio. Optimize also tells the common language runtime to optimize code at run time. By default, optimizations are disabled. Specify Optimize+ to enable optimizations.
Open the project's Property Pages dialog box. For details, see Set C++ compiler and build properties in Visual Studio. Select the Configuration Properties > C/C++ > Optimization property page. Modify the Optimization property.
To find the Suppress JIT optimization on module load (Managed only) option, select Tools > Options, and then select the General page under the Debugging node. When should you check this option: Check this option when you downloaded the DLLs from another source, such as a nuget package, and you want to debug the code in this DLL.
To find the Suppress JIT optimization on module load (Managed only) option, select Tools > Options, and then select the General page under the Debugging node. When should you check the 'Suppress JIT optimization' option?
Disabling optimization may make it easier to debug some problems, although at the expense of performance. If you are using Just My Code, suppressing JIT optimization can cause non-user code to appear as user code ("My Code").
If the mapping is less direct, debuggers are frequently unable to tell you the value of local variables, and code stepping and breakpoints might not work as you expect. For more info on JIT (Just In Time) debugging, read this documentation.
Suppressing JIT optimization means you are debugging non-optimized code. The code runs a bit slower because it is not optimized, but your debugging experience is much more thorough. Debugging optimized code is harder and recommended only if you encounter a bug that occurs in optimized code but cannot be reproduced in the non-optimized version.
If you clear the Suppress JIT optimization on module load option, you can debug optimized JIT code, but your ability to debug may be limited because the optimized code does not match the source code. As a result, debugger windows such as the Locals and Autos window may not display as much information as they would if you were debugging non-optimized code.
It means that JIT code will not be optimized for debugging. For example:
private int Add(int x, int y)
{
int notUsed = 2;
return x + y;
}
in this code notUsed variable will be excluded fro JIT code by optimization as this code is not required. If you start debugging optimized code it may look like not the code you have written (but will do the same). Another example of optimization is methods inlining.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With