Introduction
In this blog, we are discussing the importance of debugging and release. Debug and release are build modes.
Let's discuss the differences in Debug and Release.
1). Priority of the build mode.
Debug Mode: When we are developing the application.
Release Mode: When we are going to production mode or deploying the application to the server.
2). Code optimization
Debug Mode: The debug mode code is not optimized.
Release Mode: The release mode code is optimized.
Let's demonstrate the code optimization through a simple program.
- class program
- {
-
- static void main (string[] args)
- {
- M1();
- }
-
- static void M1()
- {
- M2();
- }
-
- static void M2();
- {
- M3();
-
- }
-
- static void M3()
- {
- throw new Exception("some error");
- }
- }
The execution of the program will be like this. The first main method will execute later, M1, M2, and M3. In the M3 method, we are throwing an exception.
Run this program in debug mode and see your output window. Please check the below snapshot.
See in debug mode we can see the complete stack trace of the program execution.
Run this program in release mode and see your output window. Please check the bellow snapshot.
In release mode, we cannot see the complete stack trace
Performance
Debug Mode: In debug mode the application will be slow.
Release Mode: In release mode the application will be faster.
Debug Symbols
Debug Mode: In the debug mode code, which is under the debug, symbols will be executed.
Release Mode: In release mode code, which is under the debug, symbols will not be executed.
Please check the below code snippet:
- class program
- {
- static void main(string[] args)
- {
- #if DEBUG
- console.writeLine("this line will be executed in debug mode only");
- #endif
- }
- }
Summary
In this blog, we discussed the debug and release mode differences.