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 12-28-2004, 10:55 AM   #1
ganja_guru
Member
 
Registered: Dec 2003
Location: Chennai, India
Distribution: Arch Linux 0.7
Posts: 393

Rep: Reputation: 30
RAM/SWAP usage


i know its a good thing that my swap is not being used...i have 1GB DDR ram...but i was curious why the swap space is being left untouched when the free ram drops down to even 10MB....im sure my swap space is active...


in a random instance
$top

Mem: 1033396k total, 840972k used, 192424k free, 93392k buffers
Swap: 1574360k total, 0k used, 1574360k free, 496188k cached


$free -m

total used free shared buffers cached
Mem: 1009 764 244 0 91 484
-/+ buffers/cache: 188 820
Swap: 1537 0 1537

any suggestions?

and another related questions..is there anyway to purge the used ram?(something like those winblows memory managers like free ram xp pro)....is it even needed?
 
Old 12-28-2004, 12:48 PM   #2
slakmagik
Senior Member
 
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113

Rep: Reputation: Disabled
-/+ buffers/cache: 188 820

That's almost like 820MB of 'pre-swap' so to speak. 188 is the key number. Something's a little wrong with my system at the moment and I've got:

Code:
             total       used       free     shared    buffers     cached
Mem:           504        499          5          0        128         98
-/+ buffers/cache:        272        232
Swap:          526          1        525
So I've actually dipped into swap, which almost never happens, but looking at the buffers/cache line shows I'm using more non-buffer memory, with less total RAM, and I've still only just gotten to swap. Plus, that fluctuates. You may have a surge that pushes you to swap and, after it drops, you might still have some swap used. So, in sum, I don't see a problem there. There'd be a problem only if swap said 0 0 0.

As far as purging, seems like there should be, but I can't think of it. sync brings the filesystem data up to date, but I dunno about RAM. But, no, in general, it shouldn't be necessary. Maybe somebody will post up with that.
 
Old 12-28-2004, 12:54 PM   #3
masand
LQ Guru
 
Registered: May 2003
Location: INDIA
Distribution: Ubuntu, Solaris,CentOS
Posts: 5,522

Rep: Reputation: 69
Re: RAM/SWAP usage

Quote:
Originally posted by ganja_guru
i know its a good thing that my swap is not being used...i have 1GB DDR ram...but i was curious why the swap space is being left untouched when the free ram drops down to even 10MB....im sure my swap space is active...


in a random instance
$top

Mem: 1033396k total, 840972k used, 192424k free, 93392k buffers
Swap: 1574360k total, 0k used, 1574360k free, 496188k cached


$free -m

total used free shared buffers cached
Mem: 1009 764 244 0 91 484
-/+ buffers/cache: 188 820
Swap: 1537 0 1537

any suggestions?

and another related questions..is there anyway to purge the used ram?(something like those winblows memory managers like free ram xp pro)....is it even needed?
hey have u compiled u r own kernel and if yes then are u sure u have kept the swap support there in ur kernel

regards
 
Old 12-28-2004, 01:57 PM   #4
winsnomore
Member
 
Registered: May 2004
Location: USA
Distribution: #1 PCLinuxOS -- for laughs -> Ubuntu, Suse, Mepis
Posts: 315

Rep: Reputation: 31
unless you have a lot of processes and services using all the memory there is NO reason why it will get used.
with 1G ram it's likely you don't don't have a reason to use swap.
I remember days when 1G would be the total "disk capacity" on a whole bunch of machines with 10's of users :-))
 
Old 12-28-2004, 02:28 PM   #5
slakmagik
Senior Member
 
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113

Rep: Reputation: Disabled
Yeah - I've still got a box with a smaller hard drive than his RAM. Huh. As a matter of fact, about half the boxes I've ever owned would fall in that class.
 
Old 12-28-2004, 02:32 PM   #6
masand
LQ Guru
 
Registered: May 2003
Location: INDIA
Distribution: Ubuntu, Solaris,CentOS
Posts: 5,522

Rep: Reputation: 69
hey guys
we are getting off the track
the problem here is ,how to ensure that the swap too gets used??

regards
 
Old 12-28-2004, 02:57 PM   #7
slakmagik
Senior Member
 
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113

Rep: Reputation: Disabled
Well, there's no problem. His swap is initialized and he's not maxed on physical memory, so it simply won't get used because it doesn't need to. But if it was needed, I'm sure it would be used. Like I say, it'd only be a concern if swap read zeros all the way across or he *was* maxed out on physical RAM and still wasn't swapping.
 
Old 12-28-2004, 08:37 PM   #8
ganja_guru
Member
 
Registered: Dec 2003
Location: Chennai, India
Distribution: Arch Linux 0.7
Posts: 393

Original Poster
Rep: Reputation: 30
thanks for the replies:

masand: yes i have compiled thelatest 2.6.10cko kernel, with the con kolivs patch to use 'high memory off(for 1GB machines),and swap is definetly on

well the free -m i posted was only a random instance...the point is i have my box running for days..and ive NEVER EVER seen swap being used...even when i had 512 MB DDR ram...thats what worries me...

oh and i know that when apps are executed once they get loaded into the memory...so technically my startup of apps should be faster...and they are, but only for a little while...but..

let me illustrate.

1. open firefox (5 seconds)
2. close firefox.
3. open firefox again (1-2 seconds)

but, if i do this:

1. open firefox
2. close firefox
3. open Open office
4. open xmms
5. blah blah
6 open firefox again(now its slower than the previous time...i.e more that the ususal 1-2 seconds )

my biggest problems occur when i copy huge files from vfat to reiserfs/4...thats slows everything to a crawl and maxes out ram usage...but swap is never used even then..

thanks again!
 
Old 12-28-2004, 10:42 PM   #9
masand
LQ Guru
 
Registered: May 2003
Location: INDIA
Distribution: Ubuntu, Solaris,CentOS
Posts: 5,522

Rep: Reputation: 69
hey can u tell me what options have u enabled in ur kernel that make u sire that u have enabled the swap in ur kernel

coz, i do not use swap inmy system so i have turmed them off!!

regards
 
Old 12-28-2004, 11:07 PM   #10
irwinr
LQ Newbie
 
Registered: Dec 2004
Location: Texas
Distribution: Fedora Core 6, CentOS 4.4, CentOS 5
Posts: 14

Rep: Reputation: 0
Swap use is not a good thing.

100% memory use -is- a good thing. (Because 75% of that is usually just buffers/cache)

Using swap slows things down roughly 1000% (yes, that's 4 zeros).

There are 4 types of memory: User, Shared, Buffers, and Cache. Buffers and Cache can be considered 'free' memory, they exist only until a 'real' application needs some memory that they occupy, then Linux just re-assigns that memory to that application. These buffers and cache improve the performance of your system, because reading data from physical memory is anywhere from 100-1000 times faster than reading it from disk (swap). Linux stores data in these buffers and cache that it may need again later. (Buffers and cache never hurt you. Having alot of User and Shared memory is what you need to worry about.)

But, you have to realize that there is no benefit from storing these in swap, because the data in these buffers and cache is stored on the disk somewhere already.

Quote:
1. open firefox
2. close firefox
3. open Open office
4. open xmms
5. blah blah
6 open firefox again(now its slower than the previous time...i.e more that the ususal 1-2 seconds )
That is exactly how it should be. Like I said earlier, Linux dumps the buffers and cache when other programs need that memory. So if you -try- to use up all your memory, Linux will dump the cached copies of firefox. What you need to understand is that even if Linux put that cache in swap, it would be no faster than loading firefox directly from disk. Either way it loads off of the disk. There's no point in having two copies of the same thing on disk.

Quote:
my biggest problems occur when i copy huge files from vfat to reiserfs/4...thats slows everything to a crawl and maxes out ram usage...but swap is never used even then..
Swap is generally only used when you try to use more memory than you actually have. When you copy large files, Linux does caching to improve the performance of the copy. (It's faster to read large blocks of data from disk at once, store those blocks in memory temporarily then write them to disk). The more memory you have, the more that can cached into memory to speed things up. Linux knows this, and it uses up all available memory, but no more, to make things faster. Your system is slowed to a crawl because it takes alot of processing power to handle a large file like that, especially if you have standard IDE drives that require the processor to handle alot of the work of copying files.

Swap doesn't get used because that would defeat the purpose. swap is -stored on the disk-. If you are reading from a disk, storing cache from that read on that disk will slow things down, not speed them up. So Linux just doesn't do it.

Also, keep this in mind. If you really maxed out your RAM, and swap really -wasn't- working, whatever program you have that's using all that memory, would get an "Out of memory" error and be killed by the kernel.

Let Linux do it's job and handle the memory for you. It does an excellent job. And no, the RAM purgers are pointless. They are pointless on Windows too. Most of them are gimmicks to get spyware/adware on your system.

-Jeremy
 
Old 12-29-2004, 01:15 AM   #11
ganja_guru
Member
 
Registered: Dec 2003
Location: Chennai, India
Distribution: Arch Linux 0.7
Posts: 393

Original Poster
Rep: Reputation: 30
masand : CONFIG_SWAP=y...and then u have to do a mkswap /dev/hdx ( and swapon /dev/hdx ater that ??)

irwinr: thanks for the detailed reply...guess that sorts out the ram stuff...my speed issues exist AFTER copying large files ..thats the annoying part...is there any workaround for that..?
 
Old 12-29-2004, 02:20 AM   #12
irwinr
LQ Newbie
 
Registered: Dec 2004
Location: Texas
Distribution: Fedora Core 6, CentOS 4.4, CentOS 5
Posts: 14

Rep: Reputation: 0
Not really. New buffers push old buffers out of memory. So when you copy large files, the new buffer created by the copy command pushes the old cached copied of things like firefox out of memory.

So, it's not really a speed issue. After copying a large file, your programs will start no more slowly than they would if you had just rebooted the computer (Which would clear out the cache). For me, after I do memory intensive tasks (Which kill my cache), my system is just slightly sluggish for a few minutes. But after using all my regular apps for a few minutes, the cache gets built back up and I'm back to multi-tasking like a son of a gun.

As far as a workaround.... Not really. I mean, there may be a way to configure the your copy file utility (Which utility are you using, btw? Just the standard 'cp'?) to only use so much memory for buffering. If not, you could write up a quick file copy utility in C and make it use whatever amount of memory you want. But, it won't be as fast. Think about this:

If you make it so less data is buffered, you make the whole file transfer take longer. And while the transfer is taking place, your machine is probably -really- slow.

Would you rather have your system tied up copying files for a longer amount of time, or would you rather have it get the file transfer done, and be slightly sluggish for 2 or 3 minutes afterward?

-Jeremy

P.S. What exactly is the nature of these large file transfers? Are you copying data between two different disks in the same system? Or are you copying data between two partitions on the same disk? Or are you copying data across a network? What kind of drives are you using (SCSI, IDE, SATA. Any RAID?)
 
Old 12-29-2004, 02:20 AM   #13
masand
LQ Guru
 
Registered: May 2003
Location: INDIA
Distribution: Ubuntu, Solaris,CentOS
Posts: 5,522

Rep: Reputation: 69
this seems fine!!
i remember making a logical drive as my swap partiton and that did nor work
making a primary one worked though
if u can try that ,give it a try

regards
 
Old 12-29-2004, 03:17 AM   #14
ganja_guru
Member
 
Registered: Dec 2003
Location: Chennai, India
Distribution: Arch Linux 0.7
Posts: 393

Original Poster
Rep: Reputation: 30
either drag/drop with kde or just the cp command..anyway my systems behaviour is exactly the same as yours so i guess theres no need to worry..usually my copying is dont across diff filesystems...sometimes across diff disks and filesystems...thanks for all the help..!
 
  


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
RAM usage question. 99%? TheVrolok Linux - Newbie 2 11-28-2005 08:49 PM
Odd swap usage even though there is free RAM Artanicus Linux - Hardware 5 09-28-2005 02:25 AM
Swap Usage ComputerErik Slackware 3 05-06-2005 02:33 PM
Problem with RAM usage! shazam75 Linux - Software 5 11-14-2004 06:58 PM
RAM usage Serena Linux - General 1 08-12-2003 10:50 PM

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

All times are GMT -5. The time now is 10:19 PM.

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