Had the same issue. See if any of the following helps.
import sage.libs.ecl
sage.libs.ecl.ecl_eval("(ext:set-limit 'ext:heap-size 0)")
From the discussion here: https://groups.google.com/g/sage-support/c/nieHqAWPHpQ?pli=1
A more in depth discussion is available here.
https://github.com/sagemath/sage/issues/6772
And the memory limits that you can change can be found here on the manual.
Feel free to correct any mistakes, as I am also in the process of learning Sage.