By default IDEA seems to be given only max 256mb of memory. Now, to be honest that it quite low. So I had to configure the java VM options.
Naturally my first step was to google for it. There are numerous articles about configuring the vm option for Windows and Linux.
For the benefit of those readers who found my article first the answer for Windows and Linux users lies in the /bin/ directory of the Intellij IDEA installation.
There you should be able to find idea.vmoptions file. There you just need to set the parameters you need.
For example: -Xms128m -Xmx512m -XX:MaxPermSize=128m
Now, unfortunatelly Mac uses, such as myself will find that this method simply does not work. Nomatter what you specify in the file it just seem to be ignored, and infact that iswhat actually happens, since mac version of IDEA uses MAC plist files for all its settings. So what you need to do is find the IDEA app (mine is in the default application directory). There you need to locate the IDEA app file, right click it and select Show Contents from the menu. This will open the contents as a directory in finder. From there navigate to Contents directory, where you will see Info.plist file. Navigate to Java VM property and adjust it from there.