Nextcloud server RAM issue

I’m very familiar with this issue, as I struggled with it for over two years on my Nextcloud Snap and Nextcloud AIO servers (both running on Ubuntu Server).
Just like in your case, my server kept crashing, especially when uploading larger files. I tried to address the problem by clearing the memory every minute via cron, but this didn’t help much.

To minimize crashes, I started uploading larger files via SSH and then rescanned the files on the server.

Recently, however, I managed to resolve the issue. I use self-hosted VMs on Proxmox and configured them according to my own guide, which I’ve detailed in this post: https://help.nextcloud.com/t/nextcloud-with-dietpi-lxc-or-docker/210378/2?u=vawaver.

Since I don’t know what platform you’re running on, I can’t say whether my approach is directly applicable to your setup, but I recommend giving it a try if possible.
Feel free to reach out if you have any questions.