Debug version and Relase version comparison

Source: Internet
Author: User

Preface
always know that there is a debug version and Relase version, has not been particularly clear about what the nature of the difference between the two, so do a comparison here, here to Hellworld code for example.
Code:
   
 
  1. #include <Windows.h>
  2. #include <tchar.h>
  3. int _tmain(int argc, TCHAR *argv[]){
  4. MessageBox(NULL, L"Have a test", L"OK", MB_OK);
  5. return 0;
  6. }

One, sizeThere is a substantial difference between the size of the two, and the size of the two is very different. You can see that the debug version is 5 times times faster than the release version, so what is the result that release is so much smaller than the Dbueg version?
    • The debug version, also known as the Debug version, compiles the result with debug information and does nothing to optimize the application to provide the developer with a powerful, virtual debugging capability
    • Release version, often also known as release version, does not save debug information, and has been a variety of optimizations to achieve the minimum and optimal speed of aunt.

A lot of friends want to ask again, so debugging information is what information to write it? What did the release do to optimize and optimize?
    • Debugging information
For example, when you debug your code, you get the next breakpoint, so how does the debugger know you have a breakpoint? That is, our debugging information will tell the debugger. In peacetime debugging we will also go to see if the value of the variable is as much as we expected, here is the debugger through debugging information to find the value of the variable and show it. To know more about debugging information just, you can look at the compiler principle related things, the façade of the more detailed
    • release optimization
      1. The first should be debugging information, release does not contain debug information
      2. Optimization of variables, debug version If the variable is not initialized, the variable is automatically initialized to 0XCC, and the dynamically allocated memory is assigned a value of 0XCD. The release version does not initialize the variable, and it does not handle the data in memory when the memory is dynamically allocated
      3. memory allocation length processing, debug version allocation bytes in 32bytes, release is in 8bytes units. For example, the definition of int num[4], in the debug version can allocate to the memory length is 32byte, but in the release version can only be assigned to 16byte               nbsp;
      4. release version for frequently used variables automatically turn them into register variables to speed up the program
      5. The compiled program, the debug version contains the source code to facilitate debugging, But release does not contain.
debugging information about debug and release optimization There are a lot of places do not talk about, here only to say a ballpark, let everyone probably know the concept of these two, determine what the two exactly do. second, the festivalas shown, the debug version has two more sections than the release version, and the. TEXTBSS and. Idata Two sections Let's talk about these two knots .
    • . TEXTBSS is an incremental link and a dynamic build service, disabling incremental linking causes the dynamic compilation feature to be unusable, no dynamic link is used to load the function, and the release version is optimized
    • . idata contains the function technical bureau information of other foreign DLLs, that is, the input table, merging the idata chunks into another chunk is now a convention, typically. Rdata chunks, by default, the connector will only be created when you create a known line file in your release mode. idata Merge to another area

Iii. Ida anti-compilation
    • Release version is relatively concise, is directly a function call no additional extraneous information
    • The debug version is a lot more complex, with a lot of debugger information and some system function calls. A simple MessageBoxW function call that appears at multiple function layer layers called
Summary to this





Null

Debug version and Relase version comparison

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.