开发者

Boost Exception handling

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 implicat开发者_Python百科ions 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!


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.


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.)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜