BrendanChandler
Programmer
I have an ASP app that has been running fine for months on several client systems. This week one of their ISPs pulled the plug on the site saying that it was draining resources on the shared server and therefore it needed shutting down. The most likely code was 'poor' programming resulting in leaving resources open on the server.
I am always very careful to
recordsetname.close
set recordsetname = nothing
con.close
set con = nothing
at the end of all the ASP scripts, including the names of all the recordsets I have used. The app is, however, quite large and being human it is possible to miss one occasionally. I have found one recordset not being closed and corrected this but am still battling with the ISP to a) get the site up again and b) for him to provide more information about what scripts, tables etc are involved in the problem.
I am concerned that the code has been running for months on this site unchanged without problems and for months with at least 8 other customers on other shared server sites with with much more traffic and several of them with this same ISP who has not complained about the other sites.
In order to cover myself I would like a 'belt and braces' approach to slip in a routine, perhaps in a common footer file which is included at the bottom of all my scripts. I wanted to include some code that would check if the record set still exists, if so is it open and if so close it and release it. Is this a practical solution and if so what might the syntax look like?
I have tried
if isobject(recordsetname) = true then
recordsetname.close
set recordsetname = nothing
end if
but it seems that if recordsetname has already been release the isobject still returns true which is totally misleading!
I also considered another approach which suppresses all errors then attempts to close all tables and release objects even if they have already been released e.g.
on error resume next
recordsetname.close
set recordsetname = nothing
con.close
set con = nothing
Obviously each of the examples above will list all possible recordset names that might be used anywhere in my application
Are either of these solutions practical or is there a much neater way to ensure in a footer include file for example that all resources have been released (I must say I find ASP and Windows 2003 in this area rather primitive that it cannot simply close everything automatically when a script finishes or have a short timeout to release resources - a simple command CLOSE DATA ALL has been doing the job in FoxPro for over 15 years now and all I am trying to do is put some of that functionality on the web!)
Any help here really appreciated. Thanks
I am always very careful to
recordsetname.close
set recordsetname = nothing
con.close
set con = nothing
at the end of all the ASP scripts, including the names of all the recordsets I have used. The app is, however, quite large and being human it is possible to miss one occasionally. I have found one recordset not being closed and corrected this but am still battling with the ISP to a) get the site up again and b) for him to provide more information about what scripts, tables etc are involved in the problem.
I am concerned that the code has been running for months on this site unchanged without problems and for months with at least 8 other customers on other shared server sites with with much more traffic and several of them with this same ISP who has not complained about the other sites.
In order to cover myself I would like a 'belt and braces' approach to slip in a routine, perhaps in a common footer file which is included at the bottom of all my scripts. I wanted to include some code that would check if the record set still exists, if so is it open and if so close it and release it. Is this a practical solution and if so what might the syntax look like?
I have tried
if isobject(recordsetname) = true then
recordsetname.close
set recordsetname = nothing
end if
but it seems that if recordsetname has already been release the isobject still returns true which is totally misleading!
I also considered another approach which suppresses all errors then attempts to close all tables and release objects even if they have already been released e.g.
on error resume next
recordsetname.close
set recordsetname = nothing
con.close
set con = nothing
Obviously each of the examples above will list all possible recordset names that might be used anywhere in my application
Are either of these solutions practical or is there a much neater way to ensure in a footer include file for example that all resources have been released (I must say I find ASP and Windows 2003 in this area rather primitive that it cannot simply close everything automatically when a script finishes or have a short timeout to release resources - a simple command CLOSE DATA ALL has been doing the job in FoxPro for over 15 years now and all I am trying to do is put some of that functionality on the web!)
Any help here really appreciated. Thanks