Guys, I need help (this post is long… sorry, just want to be very concise). I’ve been trying to track down and solve this problem. Have been working on it daily, pushing through new updates with the changes. Everything seems to be good to go for a couple of hours, then BOOM! Users are getting kicked out of the app. And when I look at the memory report tool, it looks as though the app restarted on its own, making all current users to be taken back to the login page. I have the app email me when there is a user logging in when the user is already logged in. If the app crashed on them, their login details never successfully saves as “logged out”, and they go an log back in, the app sees it’s a dup, and sends me an email.
Today’s update was this afternoon. A couple of hours went by. I checked the memory report before shutting down for the day (about 70MB with 9 current sessions and 33 total sessions). The Xojo statistics window showed 45% memory. Not a ton of users at any given time, and memory per Xojo was not way up there. I go downstairs to workout and am checking my emails, and all of a sudden, I see a dozen or so emails from the app with users who had to log back in. I check the memory report page, 15MB, 1 current session, 1 total session (this was me checking the report)
I posted a similar topic last week, but I thought of making a new post with as many details as I can to see if you can help
First, this seems to be a new issue as of the past 3 weeks. I thank Greg for his explanation on circular reference in the above post, but if that were the case, would not the issue have been going on for much longer? Yes, on occasion, some users would have to re-log back in, but the app never restarted itself, kicking everyone out. In fact, weeks would go by, I would check the memory report, and once I saw that or the Xojo statistics memory getting up there, I would manually restart the server so all apps would restart, and the memory would come back down. When I would do this, the memory report would show hundreds of total users from the last time the app/server was restarted, not only 33 and then minutes later 1 without human intervention. With all that said, I am not certain this is a circular reference issue as I would have expected this to be happening over the past 2 years, but it’s only in the past 3 weeks that I notice this auto-restart
Here is a basic timeline of the changes I made over the past couple weeks. Note, after each update, the app was fine for about an hour or two, and then the auto-restarts/kickout users began:
- April 22 (this is when the problems began): I updated Xojo to 2025 R1 (previously was using 2024 R3). Added a WebToolbar to all webpages. Added an accessibility feature that puts a small colored border around controls the mouse is hovering over
- April 29: I removed that accessibility feature as after looking more into it, it could have been contributing to memory leaks as it was looping through all the controls on a page
- April 30: I removed any ContainerControls I had in the app. I did this after reading Greg’s comment in the linked post above that ContainerControls can add to circular reference issues. I only had a few of these, and they were merely there to declutter the pages for myself. They did have references back to their parent pages. Taking the controls/properties/methods off of the containers and moving right onto the page wasn’t a huge task… but it made no difference with the app auto-restarts
- May 5: Please don’t scold me on this one… I have not been using Try…Catch or UnhandledException in my apps. The May 5 update added in some Try…Catch on some pages I thought to be problematic and UnhandledException, but only in the Session class
- May 6 (today): The auto-restarts were still occurring. This got me thinking… duh, I never added UnhandledException to the App level. If the app crashes from some other area I missed, the app-level will catch that and prevent the crash. Pushed through the update today, feeling very confident. Two hours later, crash, auto-restart, users mad
Here is my code in the App.UnhandledException:
If error <> Nil Then
Var type As String = Introspection.GetType(error).Name
Var msg As String = "App-Level Exception at " + DateTime.Now.ToString + EndOfLine + EndOfLine
msg = msg + "Type: " + Introspection.GetType(error).Name + EndOfLine
msg = msg + "Message: " + error.Message + EndOfLine + EndOfLine
msg = msg + "Stack:" + EndOfLine + String.FromArray(error.Stack, EndOfLine)
EmailMeError(msg)
End If
Return True
My understanding after reading the docs that if Return True
, the app should not crash, rather just continue uninterrupted. The code is identical in the Session.UnhandledException, except the msg begins with “Session-Level Exception”
If you notice here, the app should be sending me an email. It worked in testing, but it is not sending the emails at the app level, which I was hoping for. The stack showed me a nice path down to the method or button where the error occurred, along with the type of exception. I thought this would be the end-all to the issue. It wouldn’t crash the app for all users, and it would guide me on where to focus attention. It is sending me an email on the Session level, but this was a Nil issue in the UserDisconnected, which I corrected but have yet to push out. I also have similar EmailMe functions on specific page methods. None of these emails are being sent. That could be because I added Try…Catch in the wrong places
Should I do any of these?
- Revert back to using 2024 R3. I hesitate ever doing this as I always worry about any new/updated features that won’t work with older versions. I usually see that message pop up when opening a project made on a newer version and get scared
- Should I not use both App.UnhandledException and Session.UnhandledException? Should I use only one, and if so, which one? Guessing at least the App level
- Not mentioned in my timeline, but back in December, I added
Self.Quit
in the Session.UserDisconnected to hopefully clean up any leftover things to free up memory. Should I omit this? The auto-restart issue didn’t occur from December to April, so I don’t think this is a problem
I also emailed @Jason_Parsley earlier tonight to ask if he can take a look at my server to see if anything looks off (using up too much disk space… I think my small server is good for 5GB, and some of my database tables are chunky… One is 1.4GB with just over 1 million rows. Other tables are 25MB or less). Should I remove old, unneeded data to free up disk space? Could that be the cause of my app woes?