Alex Rivera | Logout

The "Optimize code" checkbox in Visual Studio. What exactly does it do?

Asked 2009-08-21T22:10:40.237
20

The Build tab of the Project Properties in Visual Studio 2005/2008 contains the "Optimize code".

The documentation states that it "... enables or disables optimizations performed by the compiler to make your output file smaller, faster, and more efficient."

  1. My question is why should I NOT have it on?
  2. Why is it not on by default?
  3. What does it actually do?
Edit
Report

1 Answer

29
  1. You wouldn't want this on for a debug built, as it makes stepping through code harder as the actual code that is running may not properly reflect what you have written (since some lines will be optimized out)

  2. It is not on by default for DEBUG builds for the above reason, it should be enabled by default on release builds

  3. It performs optimizations such as dynamic inlining and removing unneeded local variables. Any sort of optimization that can be decided upon at compile time.

answered 2009-08-21T22:13:29.873

Your Answer