Photo preview generation crashes server

I recently made the move from NextCloudPi to Nextcloud AIO.
Now when I try to load the photos page there is a huge load on the server. I tried using the previews generation app to pregenerate them, but seems those previews aren’t used. I have many HEIC files, and seems like those need a lot more work to be processed than videos or other image formats. The generation would go quickly and without much load until it hits a .heic, then 100% cpu and all of the ram and swap get used. I had to increase swap or the whole server would crash.
But opening the photos page still uses all the resources and after a while the server becomes unresponsive and needs to be force-restarted.
I never had such issues when using nextcloudpi and I really hope there can be a fix

A video of what happens: iCloud Photo Sharing

Some details that might be useful:
Ubuntu 22.10
Imagic has heic support
Rock Pi X
Intel Atom Z8350, 4Gb Ram
4Tb data HDD
2Tb HDD where backups are created

Bump, need help

I also have this problem. I tried setting memory limits on mariadb and restic, not sure what else to try or how to get more useful diagnostic information.

When I click on “Photos” It starts with a mostly empty page, and starts showing thumbnails, but then hangs.

The URL becomes unresponsive, and I have to ssh in. Restarting apache isn’t sufficient, I have to reboot the machine to bring the URL back up.