LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 01-06-2010, 01:33 PM   #1
devnull10
Member
 
Registered: Jan 2010
Location: Lancashire
Distribution: Slackware Stable
Posts: 572

Rep: Reputation: 120Reputation: 120
Where is my memory going??


I am running slackware 13 with fvwm. I have 4gb of RAM (although the system sees less as I am using shared graphics - I don't need anything better! ) Now, when I boot up, if I run vmstat, I get about 100M RAM used and the rest free.
After starting X, that goes up to about 200/250M RAM used (which is fine).

However, after the machine has been up and running for the day and I have been doing various things (mostly just browsing and the odd bit of text editing here and there, nothing out of the ordinary), I run vmstat and it is showing 1100M of RAM in use! Now, I obviously still have plenty left to play with, but what the hell is eating up the extra 800M of ram that I had when I started up?!?

Running "top" shows nothing obvious - most processes are just marked at 0% or memory, and the odd one which isn't is less than 1%.
I am assuming therefore there is something which is leaking memory somewhere!

Is there any way to maybe trace this and see what is doing it? I have a suspicion that it may be firefox but that's just a hunch.

Cheers!
 
Old 01-06-2010, 01:38 PM   #2
SqdnGuns
Senior Member
 
Registered: Aug 2005
Location: Pensacola, FL
Distribution: Slackware64® Current & Arch
Posts: 1,092

Rep: Reputation: 174Reputation: 174
I bet if you flush the cache it will all magically reappear. RAM gets cached and to the novice (myself) appears to being all used.

Flush RAM

To free pagecache:
echo 1 > /proc/sys/vm/drop_caches

To free dentries and inodes:
echo 2 > /proc/sys/vm/drop_caches

To free pagecache, dentries and inodes:
echo 3 > /proc/sys/vm/drop_caches
 
Old 01-06-2010, 01:42 PM   #3
devnull10
Member
 
Registered: Jan 2010
Location: Lancashire
Distribution: Slackware Stable
Posts: 572

Original Poster
Rep: Reputation: 120Reputation: 120
Quote:
Originally Posted by SqdnGuns View Post
I bet if you flush the cache it will all magically reappear. RAM gets cached and to the novice (myself) appears to being all used.

Flush RAM

To free pagecache:
echo 1 > /proc/sys/vm/drop_caches

To free dentries and inodes:
echo 2 > /proc/sys/vm/drop_caches

To free pagecache, dentries and inodes:
echo 3 > /proc/sys/vm/drop_caches
Would you know it, it has all re-appeared after running the above!
So, are you saying then that it is not actually being used, it just appears to be as it is cached? Could one assume that if it was needed then the cache would be automatically flushed by the system?
 
Old 01-06-2010, 01:43 PM   #4
cpplinux
Member
 
Registered: Dec 2009
Posts: 37

Rep: Reputation: 17
Press Shift-m in top and the processes are sorted in descending order by the memory. You can see which one takes the most memory.
 
Old 01-06-2010, 01:46 PM   #5
easuter
Member
 
Registered: Dec 2005
Location: Portugal
Distribution: Slackware64 13.0, Slackware64 13.1
Posts: 538

Rep: Reputation: 62
Quote:
Originally Posted by devnull10 View Post
I am running slackware 13 with fvwm. I have 4gb of RAM (although the system sees less as I am using shared graphics - I don't need anything better! ) Now, when I boot up, if I run vmstat, I get about 100M RAM used and the rest free.
After starting X, that goes up to about 200/250M RAM used (which is fine).

However, after the machine has been up and running for the day and I have been doing various things (mostly just browsing and the odd bit of text editing here and there, nothing out of the ordinary), I run vmstat and it is showing 1100M of RAM in use! Now, I obviously still have plenty left to play with, but what the hell is eating up the extra 800M of ram that I had when I started up?!?

Running "top" shows nothing obvious - most processes are just marked at 0% or memory, and the odd one which isn't is less than 1%.
I am assuming therefore there is something which is leaking memory somewhere!

Is there any way to maybe trace this and see what is doing it? I have a suspicion that it may be firefox but that's just a hunch.

Cheers!
Install htop and that will give you a table of per-process resource consumption in a neat ncurses interface.

Look at the memory bar: there will be the green section showing memory use by the current running processes and the orange section showing the total memory use including the kernel caches.
 
Old 01-06-2010, 02:12 PM   #6
salasi
Senior Member
 
Registered: Jul 2007
Location: Directly above centre of the earth, UK
Distribution: SuSE, plus some hopping
Posts: 4,070

Rep: Reputation: 897Reputation: 897Reputation: 897Reputation: 897Reputation: 897Reputation: 897Reputation: 897
It is odd how often this, or a variant of the confusion caused by it comes up.

Quote:
Originally Posted by devnull10 View Post
So, are you saying then that it is not actually being used, it just appears to be as it is cached?
It is actually being used, but it is being used as a cache for items that otherwise would have to be retrieved from disk. So, this arrangement speeds up your system overall, even if you cannot see which of your activities has caused the use.

Quote:
Could one assume that if it was needed then the cache would be automatically flushed by the system?
The system only uses otherwise unused memory for this, so, essentially yes.

It might be a concern if you thought that this was going to cause your memory to wear out prematurely, but, for RAM at least, this isn't the case.

BTW, vmstat showed a 'cached' entry and a 'buff' entry, and you looked at vmstat earlier; did you notice those? And thanks to SqdnGuns for the interesting approach of 'scripting' a flush of the memory; I hadn't though of that, and it can be used to demonstrate the point.
 
Old 01-06-2010, 02:35 PM   #7
devnull10
Member
 
Registered: Jan 2010
Location: Lancashire
Distribution: Slackware Stable
Posts: 572

Original Poster
Rep: Reputation: 120Reputation: 120
Hi,
Thanks for that, it has cleared up a bit of confusion!

I created a little fvwmscript to display RAM usage (as I didn't like the look of any of the existing ones out there - I wanted something very simple!) which takes the output of "vmstat -s -S M" and uses it to print to a docked window.
I guess it would be worth modifying this to display the "active memory" rather than the "used memory" field? What is the "inactive memory" field representing?

Cheers
 
  


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
pthreads virtual memory usage -- memory is not freed after thread exit minimol Linux - General 2 05-26-2009 01:19 AM
Two USB memory devies (stick memory/jump drive) one works one not Mark_in_Hollywood Linux - Hardware 5 05-20-2008 07:35 PM
Difference between resident memory,shared memory and virtual memory in system monitor mathimca05 Linux - Newbie 1 11-11-2007 04:05 AM
Help!?! RH 8 Memory Mapping -High Memory-Virtural Memory issues.. Merlin53 Linux - Hardware 2 06-18-2003 04:48 PM
RH 8.0 Mapping Virtual Memory to get access to VMIC Reflective Memory PCI card. Merlin53 Linux - Hardware 0 05-05-2003 12:50 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

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