JIT Optimization and Debugging
This topic applies to:
Edition |
Visual Basic |
C# |
C++ |
Web Developer |
---|---|---|---|---|
Express |
Managed only |
|||
Pro, Premium, and Ultimate |
Managed only |
When you debug a managed application, Visual Studio suppresses optimization of just-in-time (JIT) code by default. 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.
JIT optimization is controlled in Visual Studio by the Suppress JIT optimization on module load option. You can find this option on the General page under the Debugging node in the Options dialog box.
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.
Another important difference concerns debugging with Just My Code. If you are debugging with Just My Code, the debugger considers optimized code to be non-user code, which should not be displayed while you are debugging. Consequently, if you are debugging JIT optimized code, you probably want to turn Just My Code off. For more information, see How to: Step Into Just My Code.
Remember that the Suppress JIT optimization on module load option suppresses optimization of code when modules are loaded. If you attach to a process that is already running, it may contain code that is already loaded, JIT-compiled, and optimized. The Suppress JIT optimization on module load option has no effect on such code, although it will affect modules that are loaded after you attach. In addition, the Suppress JIT optimization on module load option does not affect modules, such as WinForms.dll, that are created with NGEN.
See Also
Tasks
How to: Step Into Just My Code