LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 06-27-2008, 11:15 AM   #1
vaibhavs
Member
 
Registered: Jun 2008
Posts: 113

Rep: Reputation: 15
Questions about "top" command


Hi,

When running the top command, I get this output {sorted by Memory}.
My query is; the 4th line shows Memory utilization of 2045 MB.
This is almost 99% memory utilization.

But the individual numbers under the "%MEM" do not addup to anywhere close to 99%.

I added all the % under the "%MEM" and it totals to 24%.
So who is using the other 75% of the memory and how do I see them ??

What am I missing here.

Please advice.

Thx
Vai

Code:
top - 15:16:37 up 17:18,  1 user,  load average: 0.20, 0.58, 0.40
Tasks:  60 total,   1 running,  59 sleeping,   0 stopped,   0 zombie
Cpu(s):  0.3% us,  0.0% sy,  0.0% ni, 99.7% id,  0.0% wa,  0.0% hi,  0.0% si
Mem:   2068724k total,  2045956k used,    22768k free,    18984k buffers
Swap:  1052248k total,        0k used,  1052248k free,  1821384k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
15248 mysql     16   0  169m 101m 5688 S  0.0  5.0   0:00.57 mysqld
26248 apache    16   0 33328  19m  20m S  0.0  1.0   0:01.14 httpd
26247 apache    15   0 33336  19m  20m S  0.0  1.0   0:00.75 httpd
26246 apache    16   0 33312  19m  20m S  0.0  1.0   0:01.63 httpd
26251 apache    15   0 33268  19m  20m S  0.0  1.0   0:02.04 httpd
26250 apache    15   0 33240  19m  20m S  0.0  1.0   0:01.56 httpd
26252 apache    16   0 33116  19m  20m S  0.0  1.0   0:01.43 httpd
26249 apache    16   0 32992  19m  20m S  0.0  0.9   0:00.99 httpd
26245 apache    16   0 33048  19m  20m S  0.0  0.9   0:00.88 httpd
26242 root      16   0 26844  12m  20m S  0.0  0.6   0:00.24 httpd
21922 root      16   0 11968 3832 8836 S  0.0  0.2   0:00.55 smbd
22410 root      16   0 11960 3620 8832 S  0.0  0.2   0:00.07 smbd
25100 root      16   0 11960 3536 8832 S  0.0  0.2   0:00.40 smbd
26212 root      16   0  8364 2816 6224 S  0.0  0.1   0:00.00 sendmail
 1528 root      16   0 11340 2700 8736 S  0.0  0.1   0:00.16 smbd
 1386 named     18   0 37392 2588 4772 S  0.0  0.1   0:00.00 named
26221 smmsp     16   0  6544 2360 5304 S  0.0  0.1   0:00.00 sendmail
26380 rscl40    16   0  8700 2308 6856 S  0.0  0.1   0:00.00 sshd
26376 root      16   0  8556 2104 6856 S  0.0  0.1   0:00.01 sshd
 1532 root      16   0  9140 2032 6920 S  0.0  0.1   0:00.11 nmbd
 1401 root      16   0  4900 1472 3436 S  0.0  0.1   0:00.19 sshd
26410 root      15   0  4888 1384 3948 S  0.0  0.1   0:00.01 bash
26381 rscl40    15   0  5592 1372 3948 S  0.0  0.1   0:00.01 bash
15224 root      19   0  5516 1160 3948 S  0.0  0.1   0:00.00 safe_mysqld
26408 root      16   0  4572 1064 3776 S  0.0  0.1   0:00.00 su
26443 root      16   0  2664  896 1620 R  0.3  0.0   0:00.04 top
 1414 root      15   0  2952  852 1684 S  0.0  0.0   0:00.00 xinetd
 1549 root      18   0  4848  752 3616 S  0.0  0.0   0:00.00 saslauthd
 1553 root      18   0  4848  752 3616 S  0.0  0.0   0:00.00 saslauthd
 1554 root      18   0  4848  752 3616 S  0.0  0.0   0:00.00 saslauthd
 1555 root      18   0  4848  752 3616 S  0.0  0.0   0:00.00 saslauthd
 1556 root      18   0  4848  752 3616 S  0.0  0.0   0:00.00 saslauthd
15313 root      16   0  1960  668 1356 S  0.0  0.0   0:00.03 crond
 1306 root      16   0  2604  584 1296 S  0.0  0.0   0:00.60 syslogd
    1 root      16   0  2296  548 1316 S  0.0  0.0   0:05.14 init
 1423 root      15   0  2936  500 1488 S  0.0  0.0   0:00.00 vsftpd
 1310 root      16   0  3148  436 1244 S  0.0  0.0   0:00.00 klogd
 
Old 06-27-2008, 11:27 AM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981
Code:
Mem:   2068724k total,  2045956k used,    22768k free,    18984k buffers
Swap:  1052248k total,        0k used,  1052248k free,  1821384k cached
Aboout a 90% of the memory is cached. This means that the RAM stores data used from previous applications (this speed up the execution of the same application if the same data are required to be loaded in memory). The cached memory is not reported as free (indeed it is not free) but it is available as soon as a running application claims it. So you may somewhat consider it as free memory.
 
Old 06-27-2008, 11:37 AM   #3
vaibhavs
Member
 
Registered: Jun 2008
Posts: 113

Original Poster
Rep: Reputation: 15
Thx colucix for your reply.
It was helpful.

Is there any way to free up the "cached" memory ??

Every 2-3 days, my web serving becomes dead slow.
Rebooting the server is the only solution.
I know, thats a wrong approach. But I do not have any other rescue.

What should I explore to get this apache issue resolved.
My apache is old, I need to upgrade!
Code:
[root@server root]# httpd -v
Server version: Apache/2.0.51
Server built:   Nov 12 2004 10:10:20
Anyother tweak on my existing box which will help ??

Thx
Vai
 
Old 06-27-2008, 11:42 AM   #4
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981
Quote:
Originally Posted by vaibhavs View Post
Is there any way to free up the "cached" memory ??
No and there is no need to do that, since it is done automatically and immediately when an application requires it. As for the Apache issue, I'm sorry but I have no experience with it. Anyway an upgrade from a so old version could be useful, if only for security vulnerabilities.

Edit: since the original question about memory usage shown in the top command is cleared, I'd suggest to open a new thread to resolve the server issue. In this way your problem will have more visibility and can be addressed from people able to give help with apache.

Last edited by colucix; 06-27-2008 at 11:47 AM.
 
Old 07-21-2008, 09:40 AM   #5
samiralmousawi
LQ Newbie
 
Registered: Jul 2008
Posts: 9

Rep: Reputation: 0
top command

I have a similar issue and I was doing the same work around (reboot), which is not acceptable by my client.
1. How can we free up the memory (clear cache)? I don't get it when you say you don't need to (then how can I reclaim memory)
2. Is there a way to know which process is filling up the cache (the culprit in my case)?

Thanks
Samir
 
Old 07-21-2008, 12:42 PM   #6
vaibhavs
Member
 
Registered: Jun 2008
Posts: 113

Original Poster
Rep: Reputation: 15
In my case, I increased the RAM.

Also, I have found that restarting httpd and mysqld helped to freeup the memory.
I agree its not the right resolution, but till the time I upgrade my Apache, PHP, MySQL, this is the only solution I have.

regards,
Vai

Last edited by vaibhavs; 07-21-2008 at 12:45 PM.
 
Old 07-21-2008, 02:14 PM   #7
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1194Reputation: 1194Reputation: 1194Reputation: 1194Reputation: 1194Reputation: 1194Reputation: 1194Reputation: 1194Reputation: 1194
Quote:
Originally Posted by colucix View Post
Aboout a 90% of the memory is cached. This means that the RAM stores data used from previous applications
It is certainly not limited to previous applications. Previous file I/O by current applications is also cached.

Quote:
you may somewhat consider it as free memory.
In this case, yes.

Quote:
Originally Posted by vaibhavs View Post
Is there any way to free up the "cached" memory ??
I think there are some very simple ways to limit and/or free cached memory (I forget the details). But there is no reason for you to do so.

Quote:
Every 2-3 days, my web serving becomes dead slow.
I'm sure the cached memory is not the cause.

You need to take a good look at top and other system measurements when the system is slow and diagnose what is really going wrong.

You'll never solve it by selecting some aspect of correct system berhavior that you don't understand and trying to turn it off.

Quote:
Originally Posted by samiralmousawi View Post
I have a similar issue and I was doing the same work around (reboot), which is not acceptable by my client.
1. How can we free up the memory (clear cache)? I don't get it when you say you don't need to (then how can I reclaim memory)
It is very common for people who don't understand memory management to think the cached memory is a problem and try to "fix" it when either nothing is wrong or something else entirely is wrong.

Your "how can I reclaim memory" directly ignores the "you don't need to".

Linux reduces the amount of memory used by the cache whenever conditions indicate that the swapping which might be avoided by reducing the cache size is likely to exceed the file I/O that might be increased by reducing the cache.

All caching and paging activities are based on predicting future accesses based on past accesses. So they will never be perfect (accurately predict future accesses). But the default methods built into Linux are much more likely to use memory in a way that achieves good performance than you are by constraining them.

Quote:
2. Is there a way to know which process is filling up the cache (the culprit in my case)?
I expect that wouldn't be too hard, but I don't happen to know the tools for measuring file I/O. But the whole thing would be a pointless sidetrack. The size of cached memory is almost certainly not your problem.

I suggest you get a copy of top from when the system is running normally (soon after reboot) and get another copy from when the system has whatever problem makes you think you need to reboot. Post those here and maybe some expert will spot the real issue you should be investigating.

If the system has plenty of memory, I would expect the cached memory will have increased and free memory decreased from the normal to the problem copy of top. That does not mean that increase in cached memory is part of the problem. Maybe even the decrease in free memory isn't part of the problem. Hopefully an expert can spot the differences that are likely to be part of the problem.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Checking multiple systems on network with command "top" using a Linux Script Echo Kilo Programming 16 06-15-2008 06:33 PM
"make" and "top" questions jonfa Solaris / OpenSolaris 3 01-17-2007 02:09 PM
Starting an xterm window that is "always on top" on command line azilkie Fedora 1 10-07-2005 09:17 PM
"Doubt in Implementing top command " manikantha Programming 1 09-24-2004 07:20 AM
"top" command memory question chanys Linux - General 4 03-14-2003 08:01 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:27 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration