Reputation: 1587
I am considering using boost exception handling in my application. The main benefit from adopting boost exception handling is I can add metadata to the exceptions. This can ease debugging and allow more information to be propagated upwards as the exception stack is unwound. However I am not clear with the performance implications of this. How is boost exception handling implemented - Are the error_info objects stored in a map internally (with log(n) insertion at every insertion)! Any known cons of boost exception handling!
Upvotes: 4
Views: 1261
Reputation: 381
Yes, the error infos are stored in a map. The cost of inserting error_info is negligible both in terms of speed (throwing and stack unwinding is probably lot slower) and space (all memory is reclaimed at the end of the catch, typically soon after all the other memory freed as the stack unwinds.)
Upvotes: 0
Reputation: 11669
As you mentioned, as far as I saw, the following load accompanies for operator<<.
new error_info
for initializing of
shared_ptr< error_info >
new
exception_detail::error_info_container_impl
for initializing of intrusive_ptr<
exception_detail::error_info_container>
operator[]
for inserting these in
std::map< typeinfo,
shared_ptr<error_info_base const> >
I cannot say whether these load matter in your situation. If you are concerned, it'd be better to measure the load in the actual environment.
Upvotes: 4