Process # include in ASP

Source: Internet
Author: User

Process # include in ASP

There are two main differences between the two methods of working with # include files in ASP and with compiled high-level programming languages, such as C + + processing include files.
First, the ASP does not remove the information that is not involved in the resulting ASP file. This is because the ASP is independent of the scripting engine and does not make too much code
Analysis. In general, if a basic syntax request is encountered for an ASP file, the information is cached (assuming the buffer is open) and sent to the appropriate
scripting engine for further decomposition, tagging, and execution.


In addition to this "dead code" problem, another difference between ASP include files and compiled languages is that each ASP file can be viewed as its own
The program. As long as one page does not contain another, in the sense of ASP it seems that they have no relationship, although both for the entire site operation is very
The essential. Therefore, an # include file that is shared by two different pages must be fully contained by two files. In essence, ASP does not have
The advantages of connectors in many high-level languages, connectors can be used to avoid the redundancy of the Code and data contained in the file.


If I put together the problem of ASP containing files that I generalize, the conclusion is that it will be destructive to the memory of a large site. Imagine
In this case: an include file contains all the shared programs that you might want to use. Following this design, the result is that all ASP pages
Must contain this critical file. If the everythingbutthekitchensink.inc after decomposition is the same as the average length of the ASP file,
Then half of the memory allocated by the ASP and used for the cached ASP file is filled with information that would otherwise be useless.

813


Calling NT Task manager/processes can see the memory being used by the site and observe how much memory is Mtx.exe
(If the site is set up as a standalone program running on IIS4), Dllhost.exe (if the site is set up as a standalone program running on IIS5),
or inetinfo.exe (if not independent, see figure below) These programs are used. Want to master how fast memory increases, a good
The test method is to start IIS and call a simple page to see the size of the memory. (Look at the memory before you call an ASP file because in the processing section
An ASP file to create some common common files). Now use other ASP files on your site and monitor each ASP text that is used
The effect of the pieces on memory.

For example, I created an ASP file. The first file, runfirst.asp, is a small file that initializes the ASP resource before observing the memory. Other than that
Two files are exactly the same except for the different # include file information they want to use. Copy these files to your Wwwroot directory,
Then run runfirst.asp, helloworld1.asp, and helloworld2.asp sequentially, performing helloworld1.asp and helloworld2.asp
After observing the memory, you will find that the latter uses more memory. This is because it uses an # include file that has a large unused program,
Bigandunreferenced, which has no effect on the results of the page, but occupies 400K of memory. In Windows Server
The following steps are performed on the W/IIS5 to get the result:

Memory 6,104k after running runfirst.asp
Memory 6,124k after running helloworld1.asp
Memory 6,544k after running helloworld2.asp

There is no obvious meaning in this order, and the result of reversing the loading sequence is:

Memory 6,096k after running runfirst.asp
Memory 6,536k after running helloworld2.asp
Memory 6,540k after running helloworld1.asp

Note that the number of start and end memory is not exactly the same, because the memory manager allocates memory in large chunks based on recent requests. But relatively speaking,
The final contour is always helloworld2.asp occupy a chunk of the memory share. These short codes can be downloaded at the end of this article. Browse the following
Code, but to distinguish between the memory:

The runfirst.asp is this:

<%@ language= "VBSCRIPT"% >
< HTML >
< head >< TITLE >seed Page to load General ASP resources</title >< HEAD >
< BODY >
<%
Response.Write "Seed page Loaded"
% >
</body >

The helloworld1.asp is this:

<%@ language= "VBSCRIPT"% >
<!--#include virtual = "/helloworld1.inc"-->
< HTML >
< head >< TITLE >hello World using little memory</title >< HEAD >
< BODY >
<%
SayHello
% >
</body >


The Helloworld1.inc code is:

<%
Sub SayHello
Response.Write "Hello World 1"
End Sub
% >


The helloworld2.asp code is:

<%@ language= "VBSCRIPT"% > 
<! --#include virtual = "/helloworld2.inc"--> 
< HTML > 
< HEAD >< TITLE >hello World u Sing a lot of memory</title >< HEAD > 
< BODY > 
<% 
sayhello 
% &G t; 
</body > 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.