systemd-run --user --scope -p MemoryLimit=2G firefox

Update /usr/share/applications/firefox.desktop so that each Exec line starts with that.

Found here