How to optimize the usage of CPU, RAM in Centos

Hi,

I have setup in AWS cloud with Centos, and its running fine for me, but sometimes I have message like insufficient memory to process the java file, anyone can help me to optimize the CPU, RAM in Centos

a) How to get the CPU Usage
b) How to kill unwanted Process in centos
c) How to reduce the RAM memory on the fly

Note: used new relic to monitor the instance, but not satisfied, Please advice thanks

Hi

fallow the below link

http://www.tecmint.com/clear-ram-memory-cache-buffer-and-swap-space-on-linux/

fallow the below article

you can get cpu load by using the monitoring commands like

#top
#w
uptime