The Infamous Debug=True Attribute in ASP.NET
page 4 of 9
by Rahul Soni
Feedback
Average Rating: 
Views (Total / Last 10 Days): 99102/ 99

Problem #3

Batch compilation will be disabled even if the batch attribute is true in the <compilation> element.

This attribute is found in your machine.config (in ASP.NET 1.1) in the compilation element as you can see below. By default, the batch attribute is set to true, but this is something which gets overridden by debug=true. This means that even if the batch is set to true, debug=true does not let the compiler do batch compilation!!! Instead, each aspx file ends up with a separate assembly as you saw in Figure 6.

Listing 4

<!-- compilation Attributes:
   tempDirectory="directory"
   debug="[true|false]"    // Default: false
   strict="[true|false]"   // Default: false
   explicit="[true|false]" // Default: false
   batch="[true|false]"    // Default: true
   batchTimeout="timeout in seconds" // Default: 15 seconds
   maxBatchSize="max number of pages per batched compilation" 
  // Default: 1000 classes
   maxBatchGeneratedFileSize="max combined size (in KB) of the generated source
   files per batched compilation" Default: 3000KB
   numRecompilesBeforeAppRestart="max number of recompilations before appdomain
   is cycled" Default: 15 recompilations
   defaultLanguage="name of a language as specified in a <compiler/> tag below" 
  // Default: VB
 -->

What does all this mean in plain English?

Well, you might have already noticed that the first time you access any page in your asp.net application, it renders a bit slowly. When you access the same page again it is blazingly fast. Now, if you access another page from the same folder you see that this page will come up fast as well. The delay is due to JIT compilation, but why do you other pages render fast? It happens because the first access to any page in the same folder compiles all the pages of that folder into one assembly. The maxBatchSize attribute is set to 1000 classes by default and this means that if there are 1001 classes, you will see just 2 DLL's being created and the first 1000 classes will go into the first DLL and so on. BUT, this happens ONLY when debug=false. When debug=true the output is something like you saw in Listing 6. Thus, if you have 1001 classes and debug=true, you will see 1001 DLL's sprayed all over your memory. This cannot be good for the worker process health. In fact, this tends to fragment the memory very badly until you start seeing Out of Memory exceptions. If you want to verify how these files get compiled into one assembly, have a look at them in ILDASM.exe.

For this sample Global.asax is compiled into 1 DLL; all the other files in the root folder are compiled into one and all the files in SomeFolder folder in another for a total of 3 assemblies!

Figure 8 – ILDasm output showing all the batch compiled pages with Debug=False


View Entire Article

User Comments

Title: NIKE NFL jerseys   
Name: NIKE NFL jerseys
Date: 2012-07-02 10:11:27 AM
Comment:
http://www.jersey2shop.com
http://www.cheapjersey2store.com
http://www.jerseycaptain.com
http://www.yourjerseyhome.com
We are professional jerseys manufacturer from china,wholesal.cheap nike nfl jerseys, mlb jerseys, nhl jerseys,nba jerseys and shoes
Cheap NFL,NBA,MLB,NHL
,heap jerseys,2012 nike nfl Jerseys,nba jersey and shorts,oklahoma city thunder jersey,official jeremy lin new york knicks jersey,NFL Jerseys Wholesale,blake griffin jersey blue,NFL jerseys For Sale online.All Our Jerseys Are Sewn On and Directly From Chinese Jerseys Factory
,Wholesale cheap jerseys,Cheap mlb jerseys,]Nike NFL Jerseys,Cheap China Wholesae,Wholesale jerseys From China,2012 nike nfl Jerseys,Jerseys From China,,2012 nike nfl Jerseys,Revolution 30 nba jerseys,jersey of nba chicago bulls direk rose ,nfl jerseys,green bay packers jerseys wholesale,Buffalo Bills nike nfl jerseys sale,good supplier soccer jerseys,cool base mlb jerseys,Revolution 30 nba jerseys,2012 stanley cup nhl jersey,
We are professional jerseys manufacturer from china,wholesal.cheap nike nfl jerseys, mlb jerseys, nhl jerseys,nba jerseys and shoes. www.yourjerseyhome.com
Title: SS   
Name: SS
Date: 2010-10-03 7:34:45 AM
Comment:
Really a commedable effort for compiling all this in one article..
Title: The Honorable Lord   
Name: Confused
Date: 2009-12-22 2:27:19 PM
Comment:
Sorry, the latest version of my post is the one to keep the older one can be discarded.
Title: The Honorable Lord   
Name: Confused
Date: 2009-12-22 2:08:55 PM
Comment:
.
WINDOWS 7, VS 2008, IIS 7.5
Beautiful write-up. Saved me the time to do it myself.

But, confused: I still do not understand the realtionship betweent he web.config debug= switch and the Configuration Manager setting to Release/Debug ?

I keep 2 separate web.config files one for the HOST one for the dev machine.

My web.config on the HOST is set to debug=false.
I never have had need to compile on the HOST(I wonder if some scenarios require that! ...besides having to DEBUG on HOST for some reason.)
_______________________________________________________
My web.config on the development machine is set to debug=true.
If I set it to false... and attempt to DEBUG... I get prompted to allow the IDE to change it to true for me...
I let it make the change and all is good, I am now allowed to debug.
ok, so far so good.

What I am confused about is the setting in the Configuration Manager(under BUILD option in VS). It is set to Release.
In my old WIN XP Pro dev env, I had to set that to DEBUG to be able to debug. In this new version, I leave it as Release.

So, when I compile(on dev machine)[dll version I will put on the HOST] I find myself making sure the debug= in the web.config is set to false.

Since the Configuration Manager setting is Release... should I not be able to simply leave the debug=true in the web.config on dev machine? Thus satisfying the benefit of avoiding to have to constantly change the setting?

Thus by implication it would mean the debug= switch in the web.config affects JIT only?

2 Notes:
- no matter how I set debug in either or both web.config or configuration manager, I get a pdb file.
- The Configuration Manager option under BUILD will not show until you visit the options and turn it on, on the latest version of VS <- what I nightmare that was to figure out.
.
Title: Pretty good   
Name: Anand
Date: 2009-11-25 11:58:15 PM
Comment:
Pretty good and detailed. We are working on perf issues on a project. This helps a lot. Thanks.
Title: Web Developer   
Name: Raghav Khunger
Date: 2009-04-11 12:51:42 PM
Comment:
Superb Article !!!!!!!!Great Explanation Rahul.
Title: For Gurpiar Singh   
Name: Rahul Soni
Date: 2008-08-01 6:24:59 PM
Comment:
Your assumption is correct Gurpriar. This article mainly talks about the JIT.

There is a pretty neat feature in .NET 2.0 which talk about deployment retail="true" which is supposed to be set in Machine.Config file and that would ensure the .NET Runtime will assume as if debug="false" in all the web.config.

http://msdn.microsoft.com/en-us/library/ms228298.aspx

Hope that helps,
Rahul
Title: Software Architect   
Name: Gurpiar Singh
Date: 2008-08-01 6:05:52 PM
Comment:
We do have debug = false set in web.config on production servers
But we have debug=true set in web.config on Build Machine, where code gets compiled for deployment

And we compile code using MSBuild, with Configuration set to release mode.

The way our Continuous Integration is set up, there is no easy way for us to set this flag to false when code is getting compiled.

So, I am assuming your post applies only while the code is getting deployed and running in production, and not when code actually gets compiled.
Title: Webserver Optimization   
Name: Venkatesh R
Date: 2008-05-12 4:00:33 AM
Comment:
Thanks a ton for the Clear explanation. This Issue causing not only the application but the server resource utilization.
Title: For Milan   
Name: R S
Date: 2007-08-22 11:11:48 AM
Comment:
Hi Milan,

Thanks for your comments.

Precompiled websites are a way to deploy. Notice that you deploy the application under a folder, but not in the Temporary ASP.NET folder. So, although the website is already compiled, it is NOT JIT compiled.

To know more about JIT, you can visit...
http://msdn.microsoft.com/msdnmag/issues/05/05/JITCompiler/default.aspx
Title: how about precompiled site   
Name: mILAN
Date: 2007-08-22 4:03:12 AM
Comment:
How about precompiled websites (in .NET 2)? Since the website is already compiled, I don't think the case is same? Am I correct?
Title: For Craig   
Name: R S
Date: 2007-08-21 7:12:10 PM
Comment:
Hi Craig,

Thanks for your comments. I just wanted to confirm whether you are getting errors when Debug=True? If you are setting it to true, why?

Also, what is the complete error message you get. Do you see anything in the EventLogs?
Title: Why do I have issues when I do Debug=True   
Name: Craig
Date: 2007-08-21 7:08:40 PM
Comment:
Thanks for the article. I modified all the web.configs on my server and everything really starts blowing up. Mostly COM+ errors that reset W3WP.exe. Obviously, this is very bad for our customers. Why would this work fine when debug=false? Is there some underlying problem in our code that is being exposed?
Title: The Infamous Debug=True Attribute in ASP.NET   
Name: .rip
Date: 2007-08-18 5:01:36 AM
Comment:
Great article!!!
Title: The Infamous Debug=True Attribute in ASP.NET   
Name: Sojesh
Date: 2007-08-15 2:02:47 PM
Comment:
Amazing stuff Rahul! Thanks for such a nice article showcasing every possible piece of information about the topic.... as usual!
Title: The Infamous Debug=True Attribute in ASP.NET   
Name: Dan
Date: 2007-08-02 6:19:00 AM
Comment:
This article is absolutely fantastic, MANY thanks :)
Title: The Infamous Debug=True Attribute in ASP.NET   
Name: Saurabh
Date: 2007-08-01 11:11:39 AM
Comment:
This is unarguably the best article i have read on "Debug=true" issue. The depth to which Rahul has gone to explain the repercussions of having debug set to true shoes his expertise and command over the subject.
Excellent job done! A must read for any Asp.Net enthusiast.

Saurabh

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-04-25 11:59:44 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search