LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 05-27-2016, 06:55 AM   #1
joemon83
Member
 
Registered: Jan 2009
Posts: 71

Rep: Reputation: 11
Active cache and buffer memory


Hi,

How do I check what amount of cache + buffer is actively being used.
Was just googling this and found that Active and Inactive parameters in /proc/meminfo gives this info. But if that was that case (Active + Inactive)kB should be equal to (cache + buffer)kB right ? But this doesn't seem to be true. Active + Inactive is a much bigger number than Cache + Buffer. Please help me, I am trying to troubleshoot an issue where the swap space usage is almost 100%, even though cache + buffer ~ 1.5G on 6G RAM system.

Thanks in advance.
Joe

Last edited by joemon83; 05-27-2016 at 06:56 AM.
 
Old 05-27-2016, 07:08 AM   #2
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,657
Blog Entries: 4

Rep: Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938
These figures might never be "exact sums."

Very high swap-space usage implies that your applications have a memory-leak somewhere. The amount of virtual memory that they think they need, and therefore that they individually have access to, is much larger than the amount of physical memory that the system can afford to give them. The culprits will have very high "swap-I/O" counts and are probably spending most of their times in "swap wait." You might smell funny hot-smoke smells from those poor disk drives.

The system will always reserve some amount of buffer memory, for the actively-open files, and this buffer allocation is probably, in this case, just being used for open files.
 
Old 05-27-2016, 07:57 AM   #3
joemon83
Member
 
Registered: Jan 2009
Posts: 71

Original Poster
Rep: Reputation: 11
Thanks for the reply.
But we can almost 3 processes which are using swap heavily, which is why I didn't suspect a memory leak.
I am going to check the swap in/out, but the highly suspect that this is not going to be high as the IO on the system is very low.
If swap in/out was was high, it should have resulted in high IO.
Also where can I see "swap wait" ?
 
Old 05-27-2016, 10:00 PM   #4
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,124

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
Quote:
Originally Posted by joemon83 View Post
I am trying to troubleshoot an issue where the swap space usage is almost 100%, even though cache + buffer ~ 1.5G on 6G RAM system.
Then concentrate on the real problem, not some irrelevant symptom.
Quote:
But we can almost 3 processes which are using swap heavily, which is why I didn't suspect a memory leak.
That makes no sense. If they are heavy swap users, they are almost certainly the problem - especially if they are increasing their usage. Swap only contains anonymous memory - that means applications.
Quote:
I am going to check the swap in/out, but the highly suspect that this is not going to be high as the IO on the system is very low.
High swap occupancy doesn't necessarily mean high swap I/O - poorly designed code can allocate memory and rarely access it. Then (continually) go do the same. Eventually the "old" allocation goes to swap and stays there.
That's a classic memory leak.
 
1 members found this post helpful.
Old 05-28-2016, 07:03 AM   #5
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,657
Blog Entries: 4

Rep: Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938
Quote:
Originally Posted by syg00 View Post
High swap occupancy doesn't necessarily mean high swap I/O - poorly designed code can allocate memory and rarely access it. Then (continually) go do the same. Eventually the "old" allocation goes to swap and stays there.
That's a classic memory leak.
An excellent point.

Many programmers these days cut their teeth on languages that provide a "garbage collector," which will periodically sweep-up memory (unless(!) confounded by "circular references"). Other languages, like C, do not. Either situation can result in a subtle bug: a memory leak. The "leaked" memory winds up in the swap file, and stays there.
 
Old 06-08-2016, 05:10 PM   #6
speirs1
LQ Newbie
 
Registered: Oct 2014
Posts: 20

Rep: Reputation: Disabled
Active and Inactive values in meminfo are not relevant swap activity. You'll find that linux memory reporting is fairly convoluted. I'd recommend you start with by looking at rates of swap and identify when and under what trend the swap partition reached 100%. i.e. was this a sudden spike in swapping or a constant slow swap rate, most importantly, do you see thrashing. Each system activity report (sar) file will contain a segment headed by pswpin/s and pswpout/s. These are your swap rates. View the current day's with sar -W or search the text archives under /var/log/sa/sarXX where XX is the day of the month.

After identifying the time and trend you can examine other stats in sar during that time frame as well as the kernel logs (messages) and any specific application logs which may shed light on application activity during the issue. Unfortunately the default historical record keeping is limited in linux. In the case of swapping it's likely that the sum total of userspace demand is exceeding physical RAM. Linux doesn't keep a record of per process usage so you likely won't be able to identify a root cause without additional logging.

Ultimately, you'll need to adress the following:
[1] Break down of memory utilization: kernel/userspace/per-process (ps aux and meminfo during the swap activity will suffice)
[2] If a specific application is utilizing a large amount of memory (usually the case) is this expected? i.e. potential bug
[3] If not, is the application and os tuned to the application workload (refer app tuning guide from the app vendor)
[4] Is the application foot print expected to reside within the allocated amount of RAM (i.e. should RAM be increased)
 
  


Reply



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
High value of cache/buffer found in Memory Utilization pugazhendhi_r@yahoo.com Linux - Newbie 4 12-31-2014 08:42 PM
How to Clear buffer/cache memory deepak_message Linux - Server 5 01-29-2013 07:56 AM
for buffer streaming which is better solution for apps to access memory buffer? dennisdd Programming 3 02-13-2012 11:07 PM
Difference between page cache and buffer cache Nayaka Linux - Kernel 5 09-28-2011 08:23 AM
Linux Memory Management - Buffer Cache brian_p_sully Linux - General 16 01-10-2010 11:20 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 02:40 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