TITLE: space overhead of using exceptions (Source: comp.lang.c++.moderated, 7 Dec 2000) HANSELMANN: Dirk Hanselmann > I don't care about the speed of the clean up code. What I'm > concerned about is the overhead of the C++ exception handling code > when NO exception occurrs, ie in the normal case. I've read that > current C++ compilers use data structures which are used to unwind > the stack when an exception occurrs. These structures are updated > when entering or leaving functions, for example. KANZE: James Kanze Most compilers use data structures which are used to find the necessary destructors to call when unwinding the stack. Generally, however, these are static structures and never modified -- in modern compilers, they are even in a separate segment, so that they have no locality with the rest of the code, and will not even be loaded into memory unless an exception is thrown. The only cost is thus a bit more disk space for the executable. On embedded systems where the entire code must be PROMable, this might make a difference. Elsewhere, I can hardly imagine it. There is also potentially some lost optimization opportunities. In practice, most compilers don't optimize to a level where this would make a difference. And the fact that the exception handling code is not in the function itself (as it would be if you checked return codes) will lead to smaller functions, and thus maybe less page faults. _______________________________________________ cpptips mailing list http://cpptips.hyperformix.com