Controlling my swap space?

b1m2x3

2[H]4U
Joined
Mar 19, 2002
Messages
2,678
Hi guys,
Recently I've been doing a lot of memory intensive stuff, and as a result i've been swapping all the time.

As soon as my box enters swap land, it gets slowwwwwwwwwww. Does anyone know of a way to say... halt everything and bring up a prompt if i'm about to swap? Also occasionally the machine's swap partition fills up and becomes completely unusable. Is there any way to stop this from happening?
 

Darakian

Supreme [H]ardness
Joined
Apr 12, 2004
Messages
4,698
Sounds like you need to add more ram or at least add more (faster) swap.
 

b1m2x3

2[H]4U
Joined
Mar 19, 2002
Messages
2,678
How much RAM do you have? How much swap partition/file do you have?

12gb ram, 24gb swap.
I know more ram is the *best* solution, but there's gotta be a better way to control swappage... right? maybe? please?
 

Langford

[H]ard|Gawd
Joined
Apr 5, 2006
Messages
1,339
What on earth are you doing that eats that much RAM? Is this a home machine? I guess you could delay your disk swap a little bit by enabling compcache. I've used it on some laptops to stretch memory a little, without a problem. I have no idea if it's reliable enough for a server situation, but on a home machine it should be fine.
 

Darakian

Supreme [H]ardness
Joined
Apr 12, 2004
Messages
4,698
Best solution is more ram, a decent solution might be a cheap SSD for swap. It seems like halting programming based on swap usage should be doable, but I've never heard of it before. If you do find a way, please post it here. I'd love to read it :)
 

b1m2x3

2[H]4U
Joined
Mar 19, 2002
Messages
2,678
What on earth are you doing that eats that much RAM? Is this a home machine?

All I'm doing is making movies. ;) It's not a personal machine at home... it's a workstation.

Best solution is more ram, a decent solution might be a cheap SSD for swap. It seems like halting programming based on swap usage should be doable, but I've never heard of it before. If you do find a way, please post it here. I'd love to read it :)

Thanks! If I come up with anything, I'll update the thread.
 

ameoba

Supreme [H]ardness
Joined
Jan 9, 2001
Messages
6,413
You can do a lot of things to control how the kernel handles virtual memory. Most of them are going to be downright useless if you're actually trying to use more memory than you physically have. You're probably better off telling the app to stop trying to use so much damned memory.
 

tom61

[H]ard|Gawd
Joined
Feb 3, 2001
Messages
1,062
You can do a lot of things to control how the kernel handles virtual memory. Most of them are going to be downright useless if you're actually trying to use more memory than you physically have. You're probably better off telling the app to stop trying to use so much damned memory.

Yeah, unless you're only a few megs into swap, having the app not take up all the physical RAM, and then some, would be the best bet. If it is a few megs, try changing the swappiness setting to reduce what's cached.
 

Eva_Unit_0

[H]ard|Gawd
Joined
Jun 1, 2005
Messages
1,991
By default, the kernel swaps before all physical memory is full, because generally you get better performance from keeping the disk cache and swapping as opposed to dumping the disk cache to avoid swapping. You can adjust vm.swappiness to change this behavior. This setting controls how aggressively the kernel swaps pages out of physical memory. It is a value from 0-100. At 100, it will always swap out to memory as much as possible and keep the disk cache as long as possible. At 0 it will avoid swapping until all memory is active, even at the expense of the disk cache.

Check the current value by running 'cat /proc/sys/vm/swappiness'

The default on my system (Fedora 12) is 60. With 12GB of ram, that's probably too aggressive. A value of 10 or 20 is probably more reasonable. Set it by running 'sysctl -w vm.swappiness=10'

You can make this setting permanent by adding it to /etc/sysctl.conf
 
Top