I was facing "java.lang.OutOfMemoryError: Java heap space" error while building my project using maven install command.
I was able to get rid of it by changing maven runner settings.
Settings
| Build, Execution, Deployment
| Build Tools
| Maven
| Runner
| VM options
to -Xmx512m