技术开发 频道

引以为戒 .NET开发者常犯的错误

  3.调试(Debug)模式下编译就用于应用环境中篇
   
  大家看下面的图片:

  有人会留意这个界面吗?有,但一定不多。

  接着,程式开发好(也包括单元测试),然后编译直接分发到应用环境。

  整个过程就结束了;谁也不曾想,这里埋下了一个深深的地雷;据微软的人讲,这样分发的程式到应用环境,你有多少内存恐怕都不够,所以微软建议我们做如下的工作:

“請將Web.config中的debug及Trace均設為False。還有您的所有程式請確保compile為Release Mode
Application set up for debugging
One reason for high memory that we see here in Support a lot is when you have debugging, tracing, or both enabled for your application.
While you are developing your application, this is a necessity.By default, when you create your application in Visual Studio .NET, you will see the following attribute set in your Web.config file:
<compilation … debug="true" />
and/or
<trace enabled="true" … />
Also, when you do a final build of your application, make sure that you do this in "Release" mode, not "Debug" mode. ”

  如果不这样做会有什么事情发生? 我分享一个同事的感受给大家:

“已经是很强悍的的DB和AP服务器(全部是刀片式服务器)了,可是问题一而再再而三地发生,那种感觉真的很无助很凄凉啊~”

   后来的结果发现是内存使用率超高,到一定限度的时候,就会反应变慢,这个时候只要重启IIS就可以好一段时间;后来分析IIS用到实体加虚拟的内存超过2G就会爆掉;

这就是原因,你想遇到吗?那就不妨试试。

0
相关文章