LinuxQuestions.org
Help answer threads with 0 replies.
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 05-09-2010, 11:43 PM   #1
afreitascs
Member
 
Registered: Aug 2004
Distribution: Debian
Posts: 443

Rep: Reputation: 30
How "to clear" memory swap?


I have 2G of physical memory and 1G of memory swap. Very rarely the memory swap is used and when usage is around 1% while, then gets a lot of free physical memory...

My question is:
It is possible to "clean up" the memory swap. Or better still (I think). It is possible to spend
physical memory for data that is in memory swap?

let me know ...

many thanks
 
Old 05-09-2010, 11:48 PM   #2
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
I guess the following would "clean up" swap:
Code:
swapoff -a && swapon -a
I don't really understand why you want to do this though.

Evo2.
 
Old 05-10-2010, 07:49 AM   #3
dh2k
Member
 
Registered: Jan 2006
Distribution: Slackware 13.0 (KDE 3.5.10 from 12.2; Xfce 4.6; Fluxbox); Slackware 13.1 (KDE 4.5)
Posts: 211

Rep: Reputation: 52
have you tried to reduce swappiness?

I use swappiness in a vice-versa way to your needs as I have old hardware on some boxes.
Currently set swappiness to 95 (0-100) on 256MB and system is much more repsonsive.

(0 - 100) == 0 never use swap;

You might want to try swap off as above post or swappiness 05 (0-100) - maybe -
or with your hardware even swappiness of 01.


For on-the-fly - Use:
Does not stay after a reboot;
Code:
sysctl -w vm.swappiness=05
I would test swappiness first 'on-the-fly' then with successful testing and to make permanent after reboots with;

Code:
cp /etc/sysctl.conf /etc/sysctl.conf_ORIGINAL
if you already have a 'sysctl.conf'


then change the last line below in /etc/sysctl.conf
Code:
# as root use 
# 'cat /proc/sys/vm/swappiness'
# to view system swappiness
###
# default is 60
###
# as root use
# 'sysctl -w vm.swappiness=10'
# to change the swappiness on the fly
###
# change the following decimal integer 
# 0 - 100 where 0 is NEVER use swap - not an altogether fantastic idea!!!
vm.swappiness=05


I agree with 'evo2':

I don't really understand why you want to do this though.


..more effort required than increased performance with your hardware..

Last edited by dh2k; 05-12-2010 at 12:49 PM. Reason: TYPO
 
Old 05-10-2010, 08:12 AM   #4
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
But the default swap behaviour is usually no problem. Can you describe the symptoms more fully and explain why you think there is a need to change?
 
Old 05-10-2010, 09:12 AM   #5
dh2k
Member
 
Registered: Jan 2006
Distribution: Slackware 13.0 (KDE 3.5.10 from 12.2; Xfce 4.6; Fluxbox); Slackware 13.1 (KDE 4.5)
Posts: 211

Rep: Reputation: 52
Quote:
Originally Posted by afreitascs View Post
My question is:
It is possible to "clean up" the memory swap. Or better still (I think). It is possible to spend
physical memory for data that is in memory swap?

let me know ...

many thanks

In a nut shell, - Yes it is - is it worth it? - well, we'll put our own value on that I guess - for learning - a defo yes.
 
Old 05-11-2010, 12:20 AM   #6
afreitascs
Member
 
Registered: Aug 2004
Distribution: Debian
Posts: 443

Original Poster
Rep: Reputation: 30
First, many thanks for answers :-)

Right now I'm out of time to provide feedback. My understanding of English is poor and time consuming in my case ...

I am very interested in the answer!

I have a case with 700M of memory and another with 2G. The first, when I use KDE
quicker to swap memory is used and pc is slow ... In the second case (2G) happens
to get the memory swap around 1% (which does not change the performace)

Thank you very much

ps: I use very Google translator
 
Old 05-11-2010, 05:11 PM   #7
Richard Cranium
Senior Member
 
Registered: Apr 2009
Location: McKinney, Texas
Distribution: Slackware64 15.0
Posts: 3,858

Rep: Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225
Quote:
Originally Posted by afreitascs View Post
First, many thanks for answers :-)

Right now I'm out of time to provide feedback. My understanding of English is poor and time consuming in my case ...

I am very interested in the answer!

I have a case with 700M of memory and another with 2G. The first, when I use KDE
quicker to swap memory is used and pc is slow ... In the second case (2G) happens
to get the memory swap around 1% (which does not change the performace)

Thank you very much

ps: I use very Google translator
OK.

In general, Linux will move a program's memory to swap space if it believes that the program hasn't been doing anything useful in a period of time.

For instance, if I were to launch Netbeans and then minimize the window that comes up, then after a period of time the operating system (OS) would decide to save all the Netbeans state to swap so that other programs could use the RAM for whatever I was really doing.

If I were to bring up the Netbeans window, I would have to wait whilst the SO loaded all the Netbeans pages from swap.
 
Old 05-11-2010, 10:45 PM   #8
afreitascs
Member
 
Registered: Aug 2004
Distribution: Debian
Posts: 443

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by Richard Cranium View Post
OK.

In general, Linux will move a program's memory to swap space if it believes that the program hasn't been doing anything useful in a period of time.

For instance, if I were to launch Netbeans and then minimize the window that comes up, then after a period of time the operating system (OS) would decide to save all the Netbeans state to swap so that other programs could use the RAM for whatever I was really doing.

If I were to bring up the Netbeans window, I would have to wait whilst the SO loaded all the Netbeans pages from swap.
Please
In your example with the minimized program, I type

swapoff -a && swapon -a (answered by EVO2 up ,thanks )

what happens with the program? The system is "smart" enough to save the data?

thanks
 
Old 05-11-2010, 11:00 PM   #9
afreitascs
Member
 
Registered: Aug 2004
Distribution: Debian
Posts: 443

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by dh2k View Post
.......................
..........................
Code:
cp /etc/syscrl.conf /etc/sysctl.conf_ORIGINAL
if you already have a 'sysctrl.conf'
.......................
........................
I did not find this file in slack ...

/etc/sysctl.conf

thanks

Last edited by afreitascs; 05-11-2010 at 11:03 PM.
 
Old 05-11-2010, 11:23 PM   #10
Richard Cranium
Senior Member
 
Registered: Apr 2009
Location: McKinney, Texas
Distribution: Slackware64 15.0
Posts: 3,858

Rep: Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225
Quote:
Originally Posted by afreitascs View Post
Please
In your example with the minimized program, I type

swapoff -a && swapon -a (answered by EVO2 up ,thanks )

what happens with the program? The system is "smart" enough to save the data?

thanks
Did you really mean to ask if the system was smart enough to read the data out of a swap partition before turning it off?

I don't know and really have no interest in finding out since I turn my swap partitions on and leave them that way.

(I do know that if your swap device fails, Bad Things Happen. That's why some people actually use a mirrored raid array for their swap partition.)
 
Old 05-11-2010, 11:32 PM   #11
afreitascs
Member
 
Registered: Aug 2004
Distribution: Debian
Posts: 443

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by Richard Cranium View Post
Did you really mean to ask if the system was smart enough to read the data out of a swap partition before turning it off?

I don't know and really have no interest in finding out since I turn my swap partitions on and leave them that way.

(I do know that if your swap device fails, Bad Things Happen. That's why some people actually use a mirrored raid array for their swap partition.)
Otherwise :
With the system running, data is lost when "cleaning" swap ?

thanks
 
Old 05-12-2010, 12:45 PM   #12
lumak
Member
 
Registered: Aug 2008
Location: Phoenix
Distribution: Arch
Posts: 799
Blog Entries: 32

Rep: Reputation: 111Reputation: 111
if you are concerned about private data that may be on the swap partition, you could always use a random generator on the swap partition.

Please double check this before performing:
swapoff -a
dd of=/dev/swap/partition if=/dev/urandom bs=512
mkswap /dev/swap/partition
swapon -a

There are also other things you can do like using cryptsetup to encrypt the swap partition and using a key file that auto unlocks it on boot.
 
Old 05-12-2010, 12:51 PM   #13
dh2k
Member
 
Registered: Jan 2006
Distribution: Slackware 13.0 (KDE 3.5.10 from 12.2; Xfce 4.6; Fluxbox); Slackware 13.1 (KDE 4.5)
Posts: 211

Rep: Reputation: 52
Quote:
Originally Posted by afreitascs View Post
I did not find this file in slack ...

/etc/syscrl.conf

thanks

I typo'ed - I have edited correctly to:
Code:
/etc/sysctl.conf
 
Old 05-12-2010, 04:53 PM   #14
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,131

Rep: Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121
This all seems pointless if you don't understand the functions and workings of the paging system.
Swapoff forces all pages back into backing RAM. If there is insufficient the swapoff fails, an the swap extent remains in use.
 
Old 05-12-2010, 11:15 PM   #15
afreitascs
Member
 
Registered: Aug 2004
Distribution: Debian
Posts: 443

Original Poster
Rep: Reputation: 30
@lumak

Quote:
if you are concerned about private data that may be on the swap partition, you could always use a random generator on the swap partition.

Please double check this before performing:
Quote:
swapoff -a
dd of=/dev/swap/partition if=/dev/urandom bs=512
mkswap /dev/swap/partition
swapon -a
There are also other things you can do like using cryptsetup to encrypt the swap partition and using a key file that auto unlocks it on boot.
Although not want to encrypt my data, my bad English and his patience,caused me to learn something more ...

@dh2k
Quote:
/etc/sysctl.conf
Sorry, I do not understand, but I did not find this file in Slackware ...


@syg00


Quote:
[This all seems pointless if you don't understand the functions and workings of the paging system.
You're right!

Quote:
Swapoff forces all pages back into backing RAM. If there is insufficient the swapoff fails, an the swap extent remains in use.
I think that this answers my question.

many thanks to you all
 
  


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
"clear" and "reset" bash commands broken AviJacobson Linux - General 6 07-03-2006 06:28 AM
"clear" and "reset" bash commands broken AviJacobson Linux - Software 1 06-29-2006 02:31 PM
Mandrake and "swap memory" yuran Mandriva 4 08-07-2005 06:05 PM

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

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