LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Does RES in top reflect any shared memory? (https://www.linuxquestions.org/questions/linux-server-73/does-res-in-top-reflect-any-shared-memory-803032/)

zQUEz 04-20-2010 06:31 AM

Does RES in top reflect any shared memory?
 
I am trying to troubleshoot an Apache/Mysql server that once every few days falls over due to memory starvation. I thought I had tuned my httpd.conf file with relativley small MaxClients and so on, but then noticed some unusual RES values in top while monitoring.

In short, `top -b -n1 -u apache` shows that I have 28 httpd processes. their VIRT is ~300MB for each process (I understand this is shared), and the RES ~50MB for each. I thought this wasn't shared. Is this true?
I just noticed 2 of the processes jump to 1.2g. If RES represents non-shared memory then concievably 1.2g x 28 processes would be a problem on an 8GB server.

Can anyone confirm whether RES is shared or not?
thanks

stuart_cherrington 04-30-2010 07:26 AM

Funny, I was looking at top yesterday trying to work out a few issues with memory allocation on an RHEL 4.7 box. From what I read RES is the amount of physical memory the process is using but does NOT consist of SHR'ed memory. So yeh, if your apache starts chewing 1.2G per process then your box is in trouble.

I believe you can set memory usage per process in Apache, but the syntax wasn't easy to find. Also check your Apache and MySQL log files to see where the memory is going.

Stuart.

johnsfine 04-30-2010 07:40 AM

I was hoping someone who was sure of the answer would reply here.

From a bunch of observations in which I think I understand the memory use and then look at the top output, I'm pretty sure the memory reported in SHR is entirely contained in the memory reported in RES.

RES in turn should be entirely contained in VIRT.

Looked at the other way, RES contains all of SHR plus some other things. VIRT contains all of RES plus some other things.

SHR is not just memory that is shared, it is also memory that could be shared. Depending on how much actually is shared, the total RES across all processes could exceed the total ram.

All of the above is from observation, not from reading the source code of top to see what it reads and then reading the source code of the kernel to see what the values top reads mean. That's why I hoped someone who had dug through that source code might answer.


All times are GMT -5. The time now is 10:09 AM.