Restart the computer when the system freeze

I'm working on a code but sometimes the memory gets full and the system freeze. I've been searching a little bit and there is an option that restarts the computer when the system freeze, but I can't find that option in my iMac. It's important to mention that the Mac is in another place. I access to the Mac through AnyDesk but as I mentioned some times the Mac freeze and I can't be in that place to reboot it manually, I want to know if there is an automatically way to reboot when the computer freeze. I'm using macOS 10.14.6.


Here is how:

sudo systemsetup -setrestartfreeze on

just need to setup this once. It keeps the setting forever, until someday you set it to off again.