It is so frustrating when this when, but don't worry, here's a simple fix.
Adobe Media Encoder shares its RAM allocation with After Effects and unfortunately sometimes After Effects takes over the allocation, leaving AME with not enough memory to continue. In this video, I suggest ending After Effects using the Task Manager which then allows AME to grab all the RAM it needs.
Mac OS users, I'm sorry, I don't know the equivalent options - if it does work for you, please post in the comments and I'll pin it.