Using Response.End instead of explicitly destroyin

Results 1 to 2 of 2

Thread: Using Response.End instead of explicitly destroyin

  1. #1
    Join Date
    Dec 1969

    Default Using Response.End instead of explicitly destroyin

    Here is an interesting piece of documentation on Response.End by O&#039Reilly&#039s ASP in a Nutshell: A desktop quick reference by Weissinger. (Pg 127)<BR><BR>Response.End<BR>"Ends all storage of information in the response buffer and sends the contents of the buffer immediately to the client. Any code present after the call to the End method is not processed. <BR>Any memory set aside by the script up until the call to End(such as database objects previously used in the script) is released"<BR><BR>Now if memory allocated to objects are implicitly released by Response.End, would you be able to use it at the end of a script instead of explictly destroying all objects? IE &#039Set objRS = nothing&#039 etc?

  2. #2
    Join Date
    Dec 1969

    Default my view

    Your question is valid. <BR><BR>Although the ASP engine is pretty good at cleaning up after itself, there is a great deal of doubt that it always does so, at least in the time frame you would want. The goal of setting your objects to nothing is to release system resources as soon as possible. In other words, you should do so as soon as you are done with that object, NOT at the end of your script.<BR><BR>Good programming practice (not just in VBScript and Jscript, but in almost all languages) states that you explicitly &#039release&#039 your objects when finished. Failing to do so can and will cuase complications in your code which may not be readily debugged or found.<BR><BR>Want an example? A script of mine which used many open files and a great deal of string space soon began to behave errantly. And I don&#039t mean in ways that you would call &#039normal&#039. Obscure error messages would appear in different lines on every run, even thought the code had not changed one bit. Eventually I could cause the server to crash by calling the script many times. Apparently there are some boundary conditions within the interpeters that are not handled very well (like running out of stack space or overruning string allocation). Once I explicitly closed and set objects to nothing (as soon as I was done with them) and cleared large strings when I no longer needed them, everything returned to normal.<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts