Forum Moderators: open
It would seem to me that once you hit a 500 error, you have no opportunity to close any of the previously opened objects, eventually causing memory leaks.
Any ideas as how to effectively remedy this?
Your error handler can then do what it needs to do (eg send you an email or whatever) and then you can response.redirect (or server.execute) to your custom 500 page.
The last suggestion is similar to an approach I use, coding this after every line that could create an error :
if err.number<> 0 then
raiseError err.number, err.Source, err.Description
It closes the objects OK but may report the wrong error if you havent trapped all possibilities.
I dont like using on error resume next - a 500 error handler would be much better.
I totally understand where you are coming from, but what about the times where errors happen before you can close the object? You're thinking of "the perfect world" a little too much.
My site gets over 8 million page views a week; I've seen just about everything happen. We currently have a complete error trapping solution in place while using On Error Resume Next, but I hate it (it's legacy) for reasons such as aspdaddy gave. I'm looking for other avenues to take, one including a custom 500 page.
I'm not looking for a way to NOT use a custom 500 page, I'm looking for a way TO use a custom 500 page. I'm just finding it hard to believe no one here has encountered this before, and has either a "Yes it can be done", or "No, I've tried this and it doesn't work".
K- You've definitely got some good ideas, keep them stewing.
You are better off trapping your errors at the page/routine you are calling them from and do the clean up there.
That's one nice thing about .Net...garbage collection.
As you suggest the only way to handle the unhandled seems to be with an appication context that has access to the connection pool / MTS.
Maybe a bespoke service ruuning that periodically checks the number of objects not pooled correctly... but isnt that what MTS objects, connectioon pooling and object brokering are all meant to do anyway?
But the original poster is using classic ASP right?
Even Microsoft has put out recommendations to schedule application restarts in IIS to take care of memory leaks, free up memory, etc. So even if you can't catch every single exception and close all the connection, destry objects, etc. it would eventually be freed up on the restart. It sounds like a poor work around to me though but it would work if you are that worried about it.