Partager via


Exception Handling Overhead 

The extra overhead associated with the C++ exception handling mechanism may increase the size of executable files and slow program execution time. The /EHsc compiler option enables C++ exception handling and unwind semantics. If you are not using C++ exception handling in your program and you want to eliminate the associated overhead, you can use the /EHsc- compiler option to turn off exception handling and unwind semantics. Note that /EHsc- is the default.

Because of the nature of exception handling and the extra overhead involved, exceptions should be used only to signal the occurrence of unusual or unanticipated program events. Exception handlers should not be used to redirect the program's normal flow of control. For example, an exception should not be thrown in cases of potential logic or user input errors, such as the overflow of an array boundary. In these cases, simply returning an error code may be simpler and more concise. Judicious use of exception handling constructs makes your program easier to maintain and your code more readable.

For more information about C++ exception handling, see the Annotated C++ Reference Manual by Margaret Ellis and Bjarne Stroustrup.

See Also

Reference

C++ Exception Handling