For those having the same problem:
- One similar question was asked here : cc1plus: Virtual memory exhausted
This dint work fine for me though.
Some people (on other forums) suggested re installing QtCreator, which dint help either.
Finally someone suggested (on other forums) to reinstall the build-essential package and it worked for me.
To make it clear, I realized ther was a process 'cc1plus' which was just taking memory continuously. After re installation also it takes lot of memory, but not enough to cause errors.