Release memory in JScript, bulk loading issues and other
Release Date: 1/24/2005
| Update Date: 1/24/2005
Nancy Michell Editor
Q: I have some questions about garbage collection in JScript®. I think there is memory leak in Microsoft® Internet Explorer 6.0, but on the other hand, it may be a loop reference problem. In my code, I assume "new object ()" belongs to JScript, and "Document.createElement" belongs to Internet Explorer DOM, so the garbage collector in JScript cannot release the DOM element. Is this correct? What is the best way to avoid this problem?
When you load your code into Internet Explorer 6.0 and click Refresh, you can observe the memory increase in "Task Manager":
For (i = 0; i <1000; i ) {// this loop enforces the Effect
Var model = new object ();
Var element = document.createElement ("
");
Model.myelement = element;
Element.mymodel = model;
Model = NULL;
ELEMENT = NULL;
}
script>
body>
html>
A: This is not a memory leak. You are creating a new text on the page! This will make the page bigger. If you have created a lot of objects that you can't get, it is a memory leak. Here, you will create a number of elements, Internet Explorer needs to save them in the correct presentation page. Internet Explorer does not know that you will not run the script that manipulates all of these objects you just created.
The memory will be released when the page disappears (when you are browsed, when you leave the browser). It does not leak. When destroying the page, the loop reference is interrupted.
Q: I tried to import some XML into the database by passing XML to the stored procedure called by the ADO.NET SQL provider. When the XML file is too large, it will fail due to SQLException exception (indicating a serious error). I failed when I traced to sp_xml_preparedocument.
When using an XML file with 43403 characters, it runs well, but if I add a character (by changing the last Vendor field from "micros"), it will fail. Parameters passing to the stored procedure are NTEXT types. I can't use bulk loading. Is this a known question? The size limit is from ADO.NET, SQL or SP_XML_PREPAREDOCUMENT? Finally, have there a solution?
A: In fact, letting you use a method of batch loading to load data into a segment table, then execute insert and update operation there. Until sp_xml_preparedocument failed, such problems have happened before. Most of them are for the following reasons: a single error character (or the characters in the error coding) make the analyzer fail; NVARCHAR truncated XML; or use text to replace NTEXT (resulting in illegal characters). Although there is a good hope, no one is the actual reason for the problem, so the next step you should take is to try the latest SQL Server Service Pack (http://www.microsoft.com/sql), the purpose is to see if this is Correct this issue.
Q: I want to design a search interface, and I want to transform the word "go". Many websites use "Go" of various languages to represent submission functions. But should I use a word or some type of icon? Can I only use an arrow icon?
A: It is similar to the arrow symbol shown in Figure 1, so their explanation depends on the positions they put. The text is no direction, so it decides where it is not related to it; meaning does not change.
Figure 1 arrow icon
However, research shows that self-reported user preferred is a button instead of other content, which is not more important than the first time I met. This is indeed this for tools or web services that are just accidentally used.
Whether you choose what tag you choose to submit a button, keep in mind that the Enter key is used as a search query submission option. Users rarely review the function of the Enter key, unless they don't have it, then you will hear comments! In addition, for the purpose of availability, the submit button illustration should be as close as possible to the submit button of the search text box (preferably on the right side).
Q: I have a question, about maintaining the data tree structure of the SQL database, and letting the tree becomes searched and faster. XML can represent this structure and I can use SQL to be stored, but I hope to quickly search the data tree. Unfortunately, the tree has a lot of branches and leaves, very similar to the directory structure in the file system, so I can't use the fixed table relationship. What is the best way to build this database structure?
A: SQLXML seems to be better at the shallow level than in the deep level. As XML nest, memory usage and processing time are also increased accordingly. Please read the following article about handling hierarchies in SQL: Expanding hieranchies.
The deeper the XML nested, the greater the overhead required for analysis or constructing (from plane data). Try using the fastest XML analyzer in the world to analyze the XML of 1,000-10,000 level depth. Try to run a simple XSLT script for the same data. The deep level is almost always more overhead than shallow levels.
When the XML is retrieved by XPath, SQLXML uses SQL Server for XML Explicit mode, which basically needs an orderly externally union. According to various industries, when the XML is constructed from planar relational data, an orderly external combination method is generally better than that in addition to mixed debris (adaptive determination therein, otherwise adjusting to avoid unnecessary combination) . SQLXML does not control the user's data layout, so adaptive storage policies are not an option.
When XML is modified via UpdateGram, SQLXML cuts the data (turn it from the hierarchical format to a flat format) and generates atom DML statements, just like your example. When the XML is inserted by bulk, SQLXML will cut data again, but the SQL bulk load operation is used. Both are very effective. For retrieval, the worst case is a choice for each element type (rather), and combines all options together and then sorted by nested primary key columns. Usually, this method will lead to two major performance issues. First, SQL Server does not optimize computing primary key columns (you should use many SQL: DataType / XSD: Type qualifiers in architectures with annotation, so SQLXML can exclude unnecessary calculations from its generated queries) . Second, an orderly externally joint range is severely exceeded (for example) hundreds of element types.
The example you reference is not a horizontal comparison because it does not generate XML. Generating a flat data representing the hierarchy is easy. The overhead portion will convert the plane to the true level representation (XML). The deeper the hierarchy, the greater the overhead required to change. If you run performance analysis tools for SQLXML, you will see that most of the processing time is converted from the data type in OLEDB and the conversion from the planar row to the XML hierarchy, rather than spending the SQL query itself. Finally, you can try to run the joint query without for XML Explicit and verify that the SQL query is not a bottleneck.
If you choose to use XML to keep the data tree structure, you should consider using SQLXML3.0 to cut the document into the SQL Server database. One possible solution is to create an XSD architecture that describes the annotation of the instance XML document. The maximum depth annotation allows you to describe the recursive tree structure. SQLXML Batch Load Features Allows you to cut this document to the SQL Server database. There are some examples in the SQLXML Help file. Please refer to the maximum depth portion, which describes how to handle XML documents for different levels (as long as they are recursive, and you can specify the maximum number of levels).
Q: I noticed that many websites that need to be logged in in order to access certain content or services, they do not directly place the login box on the home page. Most websites include a login link at some of the top of the homepage, or even place the link at all on the home page, but boots the user to the login page when the user browsing to the site section you need to log in.
The website should display the user directly on the home page to enter the login section of the username and password? Still a small login link is enough? Or, use the third choice to better, that is, when the user needs to be logged in, then it is prompted to log in?
A: In some cases, providing the username and password field on all pages may also be appropriate, rather than putting the username and password request field on the home page or only on a separate page dedicated to login. This does take up some screen space, but it can remind the unregistered user: If they log in, more information will be obtained. Bring the user to a dedicated login screen will confuse, especially when you return them to the page from it.
Q: Suppose you have a function, the function is sometimes in try ... carat ... inside, but at other times. Suppose When it is in try catch, I intend to raise the same error again, but when it is not in it, I don't plan to do this, because I will get a mistake - "I have triggered an exception, but did not capture."
Therefore, only when there is a nested Catch captured it, I hope to rebound. Is there a way to determine if you triggered Catch capture? The JScript code is as follows: TRY
{// do sometying That Causees an error
}
Catch (e)
{
IF ()
{
Throw (e);
}
Else
{/ / do something
}
}
A: Sorry, there is no way to detect whether the supporter will capture the exceptions you triggered. However, your problem exposes a potential design defect in your application. All points that cause an abnormality say "there is an unexpected situation, but I don't know how to handle it." If you don't have to trigger the exception again, it will be apparent that you can handle this unexpected event. If you can handle it and continue, you don't need to raise an exception again. If you are unable to handle it, press your call to handle it. You should not decide on what you can do according to the caller, but should make decisions according to what you can handle.
If there is no caller to handle the exception, the correct approach is to stop the program. Programs that cannot be handled will be greatly destroyed and must stop it before it is destroyed. If your caller cannot handle an exception, then rewrite the callout, or no exception is caused.
In addition, do not always use an exception as a control flow in the main situation. Abnormal processing is specifically designed and implemented for managing fatal errors, so this is all of it should be used.
Q: How do you pass the form data to a web page in ASP.NET (especially in Visual Basic)? When presenting an ASP.NET web page, the form's operation field will automatically change to pass it itself. I need to display the login page, and when the user clicks "login", the form data can be passed to other websites (the established website uses Request.form to capture my data). I know that I can capture data and pass it into the query string, but this is not optional. I have to pass it to other websites.
A: If you use HTMLControl on the form, you need to do it to another page is to remove Runat = "Server" from the Form tag, and set the Operation Properties to the URL you need to pass. If you don't add Runat = "Server", the FORM element will be sent to the constant client. This does not interfere with the HTMLControl value on the form in the web form.
If you use WebControl, Runat = "Server" is required on the form. However, you can still be passed to another page. For details on this situation, see: Passing Server Control Values Between Pages.