putting memory limit before error handling so we don't init it again on error
more descriptive memory limit debugging