System freezes under load

If I play a particularly heavy game, especially a VR game, the desktop or the OS freezes (although sometimes the game itself doesnt). I believe this might be that whatever programs I run have a higher priority over the machine’s resources than the OS itself, is there a way to ensure that Fedora and the desktop always has priority for resources?

I am running Fedora 43 with an nvidia GPU