[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Controlling swap usage, is it possible?



I have a few large applications that tend to lay dormant from time to
time, and as a result Linux memory management shuffles them off to swap. 
For these applications this can mean very sluggish performance when I come
back to them (after a day or two).  Is there any way, short of lowering
the amount of swap available, to control what goes to swap and what
doesn't?  I'll readily admit I know next to nothing about the kernel's
memory management.

I don't want to stop the application from _ever_ being able to go to swap,
but I would like to restrict it from doing so unless it is _absolutely_
necessary.  I envision this as something like increasing a priority for it
to reside in physical memory versus swap space.  I've found a few
documents discussing how memory management works in the Linux Kernel, but
nothing to indicate how to override swapping.

One method I've though about is to have two swap partitions of the same
size and only have one active at a time.  Then periodically (via cron),
activate the dormant swap partition and then deactivate the previously
active partition.  This seems to cause the Kernel to shuffle a lot of
stuff back into physical memory.  However, I'm not sure that this wouldn't
possibly cause the Kernel to go about killing applications with large
memory usage as it will when you run out of usable memory.  In addition, I
would prefer to keep the application out of swap space in the first place
as much as possible.

-- 
Jamin W. Collins



Reply to: