Can you recycle Websessions?

yes this is an odd question.
Ive written a large web app as a novice web app developer. never really understanding the impact of hard references on the web session object.
Now that Im scaling it up I have a problem…

Now Im stuck…
I’m having a real battle making my web app clean itself up, and I have references that are holding on and keeping my web sessions alive.

And therefore I can’t kill the web sessions with Quit,
So I was wondering about a dirty fix just for a while…

So… is there a way to recycle web sessions that have been abandoned, for new users to log onto?

i.e. can I dish up a warm web session that no-one else is actually attached to, to a new user

(And I will continue to try and clean up my app. May have to rewrite using weakrefs )

AFAIK nope. Whenever a new client hits the app, a new session is created anyway. So you might as well let the user enjoy a clean slate.

Chase all references, and make them weak, so they do not prevent sessions to properly quit.

[quote=351276:@James Nicholson-Plank]So… is there a way to recycle web sessions that have been abandoned, for new users to log onto?

i.e. can I dish up a warm web session that no-one else is actually attached to, to a new user
[/quote]
Short answer is no.

The reason is that even though the Sessions are not being released, they’re also not accessible anymore. The reference that the app keeps has been released, so even though it still exists in memory, the app doesn’t know where.

I was expecting that answer, oh well.
Thank you gentlemen, looks like I have some serious refactoring to do to get my app to scale.

Cheers

Does your app run as a CGI or Stand Alone Web app?

My experience shows that Stand Alone apps perform MUCH better depending on your code.

I have a “test engine” that hides and changes dozens of checkboxes as the questions change after each answer. It worked ok as a CGI with one or two concurrent users but with 5 it was un-usable. I did a little work to convert it to a Stand Alone app and now it handles 25 or more concurrent users with good performance.

CGI apps leave lots of temporary loop back connections (at least on Windows) and that can be a problem. Stand Alone apps seem to be much better at managing sessions.

I wrote some posts, as well as others, about using NGNX as a “front end” Web Server to force HTTP to HTTPS and NSSM (Non Sucking Service Manager) to set up a Stand Alone app as a service.

I am 100% committed to Xojo as my only Web App tool and I have not found anything it won’t do … but sometimes that does take some effort. In general I now only deploy Stand Alone Web Apps.

Thanks Mark
Im CGI at the moment but I host it with Philip, and we will switch it to native soon.
The trouble is just the thousands of objects that keep accumulating because of the ZOMBIE sessions.
My own fault, I never realise the impact of hard references in a web app i.e. keeping dead sessions alive.
I look forward to running it Standalone
Cheers

One place where standalone is sluggish is with pictures, which are served by a webFile. This is terribly slow. If you can, it is much faster to store the pictures on a web space (easy with 1701) and use the URL in your app.

UPDATE: I have at last refactored enough to have all my web sessions closing :slight_smile:

How ever… I would like some insight please…
Im still leaking memory after the sessions have closed and gone to heaven?

On App startup I build a framework of datasources and data controllers to manage screens
also when I run database work I convert the sql data to objects that live in these data controllers.

My problem now is…
even though my web sessions are closing like they should and the count is dropping right back to the one I use to monitor the app…

I still retain about 12000 various objects per closed web session
( mostly dictionaries , weal refs, delegates ,and controls (info from Runtime.ObjectClass))
And I lose about 1.5 meg every session that is used and is shutdown.

I have no references to the session data on the web application object.

Obviously they are floating in the Never never land

why does this happen?

The web session that owned them is dead. I thought that was it?

How do you know you are retaining them? Just based on memory usage alone?

I create a class called “ParentSession” and multiple sessions can point to the same ParentSession so they can share information across tabs. Its up to you how strict you make this and how you want to validate the user. I usually use a cookie and then make sure their browser info matches up.

Hi Phillip and Brock,
My apologies for not acknowledging your replies as I missed the emails.
The more I play with this problem the more little wins I get with finding references I haven’t cleaned up.
But I’ve still got too many objects, mainly arrays and variants.

So thanks for the help guys.

Phillip
My login screen has a label with the data from
The Runtime object memory usage and object count and number of sessions.
So I can see the object count when the app clicks back to one session.

Cheers Brock
I’ll keep that in mind for the future.