To avoid this memory issue, increase the memory site on the config.php
Add this line
$CFG->extramemorylimit = '4096M';
Log out from the moodle and close the browser. Then open the page again and log in.
If you still run into the issue, increase the memory limit to bigger value. Once you are done, be sure to remove the line.