6. How to improve the performance of the script program
Since we are dealing with heavy object models (such as Word.Application) and application instances, it is important to note that the system's resources are shown. Once we have finished processing the application instance, we have to remove it to erase the object's instance from memory. There is only one way to implement it in JScript, which is the Quit () method of the Application object, and here's an example:
var wdapp = new ActiveXObject ("Word.Application");
Wdapp.quit (); Tidy up
In Visual Basic, unlike JScript and VBScript, setting an object variable to null does not erase memory. Also, if there are no other references to this object, such an assignment will cause the application to shut down. Unfortunately, in JScript we have to use the Quit () method to clear the object from memory when we have already used it. Setting a variable to a zero-length string or being empty is just a good exercise, and it does not erase memory.
Place a point at least code in the tutorial a procedure call has to be executed in the background. The best solution is to localize the cache object reference. In a nutshell, this technique can be applied to objects as well as automation objects. Here's a look at the script fragment:
var Exapp = new ActiveXObject ("Excel.Application");
Exapp.workbooks (1). Worksheets (1). Cells (1, 1). Value = "A-Cell";
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.