Disposal of #include in ASP

Source: Internet
Author: User

Processing #include in ASP

Processing #include in ASP

There are two major differences between processing #include files in ASP and using compiled advanced programming languages, such as C + + processing including files.
First, the ASP does not remove the information that is not involved from the resulting ASP file. This is because the ASP is independent of the scripting engine and does not do much code
Analysis. Generally speaking, if you encounter the basic syntax request 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, the other difference between an ASP's file and the compiled language is that each ASP file can be viewed as its own
of the program. As long as a page does not contain another, in the sense of the ASP they are not related, although both of the operation of the entire site is
The essential. Therefore, a #include file that is shared by two different pages must be fully contained in all two files. In essence, ASP does not have
The advantages of connectors available in many advanced languages enable connectors to avoid the redundancy of code and data contained in a file.


If you combine the problem of the ASP inclusion file that I have outlined, the conclusion is that it will be destructive to the memory of a large site. Imagine
In this case: A containing 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 document. If the everythingbutthekitchensink.inc is decomposed and the average length of the ASP file is the same,
Then half of the memory allocated by the ASP and used for the cached ASP file is full of unwanted information.

813


Call the NT Task manager/processes to see the memory being used by the site and observe how much memory is made up of Mtx.exe
(If the site is set up as a stand-alone program to run on IIS4), Dllhost.exe (if the site is set up as a stand-alone program running on the IIS5),
or inetinfo.exe (if not independent, see figure below) used by these programs. 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. (To call an ASP file before you look at memory, because in the processing of the first
An ASP file to create some common common files. Now use other ASP files on your site and monitor each ASP that is used
The function of a piece on memory.

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

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 load 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 memory at the beginning and end is not exactly the same because the memory manager allocates the memory in large chunks according to the most recent request. But relatively speaking,
The final contour always helloworld2.asp occupy a large chunk of the memory share. You can download these short code at the end of this article. Browse the following
Code, but to distinguish between memory:

The runfirst.asp is like 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 like 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 using a lot of memory</title >< head >
< BODY >
<%
SayHello
% >
</body >

Related Article

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.