Sudden memory spike in Webapp

Something strange is happening with my Webapp deployed on a DigitalOcean Debian 12 droplet.

The memory graph shows sudden spikes in memory usage:

Currently:
Running the top command on the server’s console shows the app using 1.1GB of memory

But in Xojo, Runtime.MemoryUsed returns 381 MB.

So the app is using 700MB more than what Xojo reports and I can’t explain why there are sudden memory spikes.

When analysing objects in memory, I notice that there are more than a 100 _CallLaterTimer objects in memory.
I suppose that is the base class that is used when using Timer.CallLater

Usually the app only has 3 or 4 _CallLaterTimer objects.
That could be one source of memory leaks but I don’t expect each CallLaterTimer to use 7MB of memory.

Has anyone seen this?

I have a web app that’s under fairly constant use (up to 50 users hitting it multiple times per day) and it’s chugging along very happily under 50MB of RAM.

ARM build, macOS 14.6.1.

Clearly not a direct comparison with your app, but I do wonder if there’s a linux vs. macOS difference?

Edit to add:
Are you able to do a Sample of the process’s stack trace when in this state?

Looks like a pool recreate. Sockets or sessions perhaps? But could be something else, since i don’t know hoe much memory is used per item.

Thank you both for you replies

Each session of my app uses 1.5 to 2 MB, that’s what I measured when running the app in debug mode on my Mac.

There might be a difference between Linux and macOS. Especially on the amount of memory used for low-level classes such as Sockets.

Unfortunately I don’t know how to do that on Debian 12. I’ll do some research.

I agree with you, it looks like the app is doubling the amount of memory all of a sudden as if all sockets or sessions are created again.