I’m trying to make sure that my database web app cleans up after itself.
Here’s what I currently do:
After accessing data, I close out every recordset and database connection (rs.close, db.close).
If I switch from one window to another, I make sure to use self.close to close the first window.
The thing is, watching memory use on Top, I see memory usage increase as windows open, but I don’t see it really go down after they close. Is there something I’m missing? Does closing a window free up memory from any objects it uses automatically?
Got it. I figured I would reduce memory overhead by closing them. Keeping them open certainly speeds up things if a user goes back to a page.
Is there a typical timeout for a session to automatically end? Meaning, if a user simply closes their browser, is there a default period of time that the server will end the session and release the resources back to the server?
Usually the direction where I point people is to look for circular references in their code. That is, object a has a reference to object b and object b has a reference to object a. When it comes time to fire destructors, neither one can because not all of their pointers have become Nil.
The really hard ones to track down are places where you have made references to framework objects though. Just keep in mind that to hold everything together, we keep references from parents to children when constructing in memory. This means:
App to Sessions
Sessions to Views (Pages and non-implicit dialogs)
Views to Controls (and implicit dialogs and Containers)
Implicit dialogs and Containers to Controls (and other implicit dialogs and Containers)
If at any time you make a reference in your code which makes a reference that goes laterally or up this tree, you must set it to nil when you are done with it.
For example, if you had a WebContainer with a property which points back to its Session, and the user leaves the session, when we call the Close method, the Session would get disconnected from the framework but not freed from memory because your class is technically still holding a reference to it and vice versa because the session (indirectly) holds a reference to the container.
I use Session variables to store things like a username. If a container or a webpage uses Session.username in a method to display the username on a WebLabel (Label1.text = Session.username), does that count as a circular reference? Or does it actually have to be a property that is part of the container’s design? I’m sure I probably have circular references somewhere in my project, I just want to make sure I’m looking for the correct thing.