I have the experience that Linux works fine until the physical memory is exhausted. As soon as swap space is used the performance is severely degraded and the GUI becomes unresponsive.

This problem is not limited to a specific distro or desktop, because I've tried a few (and the issue remains).

What can I do about this?

  • This is a known issue with the linux kernel... I believe I read that recently a patch was committed to fix it. Looking for a reference to that... Aug 21, 2010 at 8:14
  • 1
    This article and this one on phoronix is what I was thinking of... I think. Aug 21, 2010 at 8:33
  • basically those articles talk about patches that are going into 2.6.36 so when that comes out get that (unless you dare to run an RC or from master) Aug 21, 2010 at 8:38
  • How much RAM do you have? Which programs do you run that are so hungry? VM's? JVM?
    – tshepang
    Nov 11, 2010 at 6:23
  • I have 8GB of RAM and the culprits are the usual apps (webbrowsers like Firefox and Chrome, e-mail clients like thunderbird, and IRC clients.
    – txwikinger
    Nov 12, 2010 at 20:25

12 Answers 12


I suggest reading SwapFAQ , in particular the swapiness parameter.

  • 3
    +1, swap is a band-aid that we hope to not use... Aug 12, 2010 at 1:28
  • 1
    I have extensively tried out different settings for swappiness with no success. I have also noticed, that the opinions about the value of swappiness are not unified at all. For desktops some recommend 10, others 100, meaning they suggest they suggest the total opposite effect.
    – txwikinger
    Aug 16, 2010 at 18:43
  • 1
    After further tests, I recommend not to use either swapiness 100 nor 0. Both have created situations in which the desktop got into a swapping craze which even had the panel clock stop for more than 20 mins.
    – txwikinger
    Aug 26, 2010 at 17:56

Some pointers:

  1. Don't run so many GUI programs at once.
  2. Make sure that any programs running in the background that you don't need e.g. Apache are stopped.
  3. Use a distro aimed at low-memory situations (e.g. for a netbook)
  4. Buy more memory.
  5. Buy a faster HD (or SSD) for your swap partition. :)
  • 1
    – Frozenskys
    Feb 24, 2012 at 14:05
  • 2
    with modern SSDs the entire system is likely to be obsolete and ready for replacement long before the SSD dies. it really isn't worth worrying about these days. backups are, of course, still required because a disk - SSD or mechanical - can die at any time.
    – cas
    Aug 22, 2012 at 23:22

Purchase more memory? :)

If you are running applications that are using more memory than you have present in the system, there's nothing that any operating system can do about this other then to swap to the swap partition. If this is a situation you find yourself in often, stop running some of the programs that you do not need, or, really, buy more memory, it is very inexpensive these days.

  • 3
    I have already maximum RAM. I would like to know some tweak that make swapping more efficient than it is.
    – txwikinger
    Aug 10, 2010 at 19:58
  • 1
    I've found that disabling swap entirely tends to make a system respond faster. Apps get notified by the kernel that they don't have memory and respond accordingly.
    – cjac
    Aug 11, 2010 at 14:58
  • 3
    @cjac: That's usually not the case. You can configure the kernel to do this, but by default it will overcommit (give your app memory which your system doesn't have). As soon as an app touches memory and the kernel can't find any more the out-of-memory killer will terminate one or more processes. Aug 21, 2010 at 7:29
  • @txwikinger the reason that swapping is slow is because RAM speeds are so much faster that hard disks. RAM seek time is measured in nanoseconds (10^-9). HDD seek times are measured in milliseconds (10^-3). That's six orders of magnitude, in other words RAM is one million times faster than swap. Your question is like asking how to make a bicycle go as fast as a Concorde jet. You can't.
    – bahamat
    Jan 9, 2011 at 9:16
  • 1
    @bahamat. You are stating the obvious, but it is not the problem. The problem is that the swapping is done very ineffectively, and hence creates something in the direction of the philosopher's problem.
    – txwikinger
    Jan 11, 2011 at 17:08

Try to change the values of the kernel variables 'vm.swappiness' and 'vm.page-cluster' to more appropriate values.

  1. Start a terminal emulator.
  2. cd /etc/sysctl.d/
  3. sudo echo "vm.swappiness = 0" > 60-memory-management.conf
  4. sudo echo "vm.page-cluster = 1" >> 60-memory-management.conf
  5. sudo chmod 644 60-memory-management.conf
  6. Reboot.

Check if the new values are in use with:

  1. cat /proc/sys/vm/swappiness
  2. cat /proc/sys/vm/page-cluster

Swapping will heavily decrease performance no matter what, so it's best to avoid that altogether. This may sound stupid, but one option is to not configure a swap partition. I've been running swap-free on all my systems for some time now:

  • 1 GB on the netbook is enough for browsing the web, listening to music and other lightweight stuff.
  • 4 GB on my desktop is enough for all above things plus development (even in Eclipse) and basic image editing.

If you do something that's really memory intensive (Gimp with large images, 3D modelling, CAD) than you should probably purchase some RAM.

  • Yes. I slowly come to the same conclusion. I seems to me that the the way the Linux kernel swaps is not very efficient for desktops (on servers all of this work fine). Hence, maybe the recommendation should be to disable all swap space on desktops. Btw. I use 8GB RAM :)
    – txwikinger
    Aug 10, 2010 at 21:11
  • 1
    @txwikinger: may I ask why it is fine on servers?
    – phunehehe
    Aug 11, 2010 at 6:09

You can try compcache, if you can figure out how to set it up in your distro. For example, on Ubuntu, you can enable it by editing /etc/initramfs-tools/initramfs.conf and editing the "COMPCACHE_SIZE" line.

I don't think my on-disk swap has been touched once since I enabled compcache. Here are my current swap stats:

% swapon -s
Filename                                Type            Size    Used    Priority
/dev/ramzswap0                          partition       1028084 69504   100
/dev/sda5                               partition       3148668 0       -1

Notice that the compcache device (ramzswap0) is used, and the on-disk device (sda5) is not.


I run the System Monitor applet in a dock on the right side of my screen. Any time that the system feels sluggish, I take a look at the meters. If anything is running at above 10% capacity, that is an indication that a process is getting out of hand.

If you click on the system monitor, you can dig in to the processes that are consuming resources on your system.


  • 1
    Most systems monitors just drag down a slow system more it's Schrödinger's cat. Without increasing memory he has to fix memory leaks or trim unnecessary programs that are running.
    – jjclarkson
    Aug 12, 2010 at 16:49

A few years ago it was usual to use a dedicated drive for swap, while connected to it's own IDE/ATA bus - swapping data around on the same drive just didn't make sense in terms of performance.

That trick worked ten years ago, but with drive speeds now you really shouldn't see such hectic performance degradation, unless you're swapping the library of congress, otherwise I'd be concerned about your drive's health - have you checked that lately?

You can always give it a try, you don't have much alternatives if your RAM is already maxed out. If anything I hope it makes your GUI more responsive.

  • A lot of usages for desktop don't give this option since they are lapbooks, or netbooks which do not allow a second drive.
    – txwikinger
    Aug 16, 2010 at 18:38
  • @txwikinger obviously true, but I considered the question's title which reads "desktop", otherwise I would not have suggested this if a laptop was specifically mentioned :-)
    – invert
    Aug 18, 2010 at 8:54
  • Well.. I meant desktop in order to distinguish from servers, where I believe the swapping works reasonably well. :)
    – txwikinger
    Aug 18, 2010 at 13:28

Install a second Linux system on your network with a good amount of RAM, NFS mount it to your main system, and put the swap file on that.

  • 1
    With gigabit Ethernet, this is going to be a lot slower than a midrange SSD, and I'm not sure if you could even reach the speed of a 7200rpm hard disk. Maybe with Firewire you can reach the speed of local swap. But it would be more effective to simply add RAM. Jan 12, 2011 at 21:06

For many years experience , I can tell you there's not that much to tweak

But , what I did recently helped a lot.


I moved from Ubuntu to Arch Linux , from Unity / Gnome to xfce desktop.

Ubuntu is deadly slow , from everywhere. boot / graphics .. slow.


I bought a Intel SSD (80g) , and planted my root system on it.

My arch Linux + XFCE4 + docky + conky , boots in 10 seconds (auto login with lxdm) , all application installed on SSD , e.g Matlab , starts much faster.

The money worth it.


Make your /tmp elsewhere , I use limited size of ramdisk for it , to prevent root filesystem get scrambled


Purchase faster RAM and make sure your system is using all of it. What CPU and architecture are you using?

  • How does that tweak the Linux system? Hardware change or improvement is not the issue here.
    – txwikinger
    Aug 10, 2010 at 20:28
  • It's possible that your linux install isn't using all of the hardware available to it. This is a performance issue and you've stated in a previous comment that you're at your max RAM limit. Without knowing more details about your configuration an easy route to take is better hardware.
    – Mike H
    Aug 11, 2010 at 14:38
  • 1
    the "Linux system" is composed of hardware and software. Adding memory is "tweaking" the system.
    – cjac
    Aug 11, 2010 at 14:48
  • Linux is software that runs on hardware. Hardware is not included inside Linux :p
    – txwikinger
    Aug 16, 2010 at 18:39
  • 1
    I think that more ram is more appropriate than faster... RAM speed is limited by the Mobo usually too... Sep 18, 2010 at 18:54

One way is by using an optimized kernel.

  • Please do not just post links; include some context so that, should the site you are linking to go down, there is sufficient information here to make the answer meaningful.
    – jasonwryan
    Oct 20, 2012 at 1:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .