release 下的异常

来源:互联网 发布:catia v521软件下载 编辑:程序博客网 时间:2024/04/28 06:16

1.Release做了优化,只会检查代码中有显式throw的异常

2.终于知道了,VC在release版默认是同步异常,release版本不能捕获非法内存访问、除零等结构化异常,修改release的编译选项,加个/EHa就好了,谢谢楼上。  

3.要改成异步模式try和catch才能在Release下工作,
搜索下怎么把编译选项改更异步模式,

改后很耗CPU和内存等资源就是

4. Exception   Handling:   Default   Synchronous   Exception   Model”摘抄的:
In   previous   versions   of   Visual   C++,   the   C++   exception   handling   mechanism   supported   asynchronous   (hardware)   exceptions   by   default.   Under   the   asynchronous   model,   the   compiler   assumes   any   instruction   may   generate   an   exception.

With   the   new   synchronous   exception   model,   now   the   default,   exceptions   can   be   thrown   only   with   a   throw   statement.   Therefore,   the   compiler   can   assume   that   exceptions   happen   only   at   a   throw   statement   or   at   a   function   call.   This   model   allows   the   compiler   to   eliminate   the   mechanics   of   tracking   the   lifetime   of   certain   unwindable   objects,   and   to   significantly   reduce   the   code   size,   if   the   objects "   lifetimes   do   not   overlap   a   function   call   or   a   throw   statement.   The   two   exception   handling   models,   synchronous   and   asynchronous,   are   fully   compatible   and   can   be   mixed   in   the   same   application.

Catching   hardware   exceptions   is   still   possible   with   the   synchronous   model.   However,   some   of   the   unwindable   objects   in   the   function   where   the   exception   occurs   may   not   get   unwound,   if   the   compiler   judges   their   lifetime   tracking   mechanics   to   be   unnecessary   for   the   synchronous   model.

See   the   /GX   and   /EH   compiler   options   for   information   on   enabling   exception   handling.