Memory leak even when all sessions close? Best Practices to stop this?

First thanks for any insight that anyone can offer me.
My Question is … Can objects be orphaned on the web application object after the session object has destructed?
And if so, are there any best practices that I can use to stop this.

Im trying to understand how the WebApplication object works with objects created during a session.

My problem is a memory leak even though all of the sessions happily die when not in use.
But my App keeps getting bigger and bigger as each new session starts , is completed, and destroyed.

The Objects are accumulating in the web application even though to my knowledge I have no references to them on the actual web application class?

My Class structure in simple terms are classes looking after classes, and eventually referenced on the session. Not the App. See at bottom.

My Question is … Can objects be orphaned on the web application object after the session object has destructed?
And if so, are there any best practices that I can use to stop this.

Not sure how to go about killing objects even if I found them i.e. as there is no reference to them any more.

Again thanks in advance if you reply.

[i]//////////////// basic class structure///////////////
My web app creates objects when a new session starts up. These objects represent the data I get from the database.
They are referenced and managed by higher level Classes.
These Higher level classes themselves are managed by a singleton class.

The singleton class is attached to the web session.[/i]

Why a singleton? A session would not seem to be a place that you’d use a singleton to manage a bunch of session variables. Did you code it to be singleton local to the session only? If it’s class constructor based that would make it app wide wouldn’t it? Seems like you’d never release the last reference unless there were no sessions at all. Also if there are any other references in that singleton that aren’t session local, that could keep it around.

Sorry I probably haven’t explained myself very well.
I have One Object of an APP class in the session which controls all my other objects.
One reference to this object is held on the session.

So all my objects are controlled eventually by one object in each session. Not for the whole App

Sure, anything is possible, but without looking at your code, anything is just a guess.

First of all, you keep saying “after the session object has destructed“. I’m curious how it is that you are confirming that the session actually does get destroyed.

Hi Greg
please excuse my ignorance and naivety in this area…

I run clean up code in the session destructor and this does fire.

and the app.SessionCount drops down to one after about 3 minutes after every session has closed.
One is left open because Im using it to look at the runtime data

The Runtime.ObjectCount drops back after the session number drops,
but never to what it was. It increases for every new session started and destroyed.

Excuse my ignorance but Is the session just a global variable? And any objects I create are actually created in the web app itself? (not some sort of sealed off session area). And If I don’t manage to set class objects to nil then they will still exist in the Web App, just orphaned? Even when the session they were created under has gone?

Thanks

[quote=355926:@James Nicholson-Plank]The Runtime.ObjectCount drops back after the session number drops,
but never to what it was. It increases for every new session started and destroyed.[/quote]
Put a break point and check what objects remain in the debugger. Click on “Globals”, then “Runtime”, then “Contents”. The elements on the top of the list are the “youngest” ones.

Eli
Thanks for that. The youngest are the most interesting, brilliant, Ill have a go