Link to home
Start Free TrialLog in
Avatar of orazen12
orazen12

asked on

How to determine which program is using most memory on my unix server

Hi,
Attached is a screenshot of the top command from my unix CentOS server. It has 2GB memory and the top command is showing all the 2 GB as being used. I have be following questions:
1. Is it normal for the server to show all the memory as being used?
2. How can I find out which process is using the most memory? In the %MEM column I don't see the total usage to be more than 20%
3. If all the memory is being used then do I need to explicitly run the garbage collector to free up the memory?

Thanks.
top-command-screenshot.JPG
ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
looks like you need to configure some swap space
Avatar of orazen12
orazen12

ASKER

Thank for your reply Objects.
But as in the attachment, the top command shows does not show the memory usage to be more than 20%. Then why is it showing as all the memory being used? What I am trying to say is that if there's some other problem then even after configuring swap space it'll occupy that space too.
thats not all the processes. I suspect the os itself would be using the bulk of the memory
I agree. But my system has 2GB RAM. 20% of that would be about 400 MB. Would the OS be using 1600 MB? It is running mySQL, TOMCAT, Crontab and has Java installed. Nothing major. Earlier I had 1 GB and since when I ran my program it started showing as all the memory as being used up, I upgraded it to 2GB. Now it is showing as that also being used up completely. If I was not to run my Java program a lot of memory would be free. So I am not sure if so much memory is being occupied by the OS.
> What I am trying to say is that if there's some other problem then even after configuring swap space it'll occupy that space too.

why do you say that?
without any swap the os is going to have to hold *everything* in physical memory.
I just tried to create a swap but I can not since it's a virtual server I've taken and creating a swap is not allowed in this case. Also, all the 2 GB I'm using is virtual since it's a virtual server.

Please suggest what should I do now.

Thanks.
if its a virtual server then you should check if all those memory figures are actually for the vm, and not for the host
I am sorry I didn't get you. When I do a vmstat, get the same amount in used as in top.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If you're running in a virtual server, you need to determine from the hosting how they've got it configured
Here's the result of the command:

                                           total       used       free     shared    buffers     cached
Mem:                               2048       1481        566          0          0          0
-/+ buffers/cache:          1481        566
Swap:                                           0          0          0
Looks fine
I think the memory figures are for the VM only. When I had 1 GB it was showing 1 GB there and then I upgraded my server to 2 GB and now it is showing 2 GB. So I don't think the figures are of the host. I think it is of the VM only.
Yes, that's entirely expected
Thanks.