Results 1 to 6 of 6

Thread: Ubuntu is not using swap space

  1. #1
    Join Date
    Jun 2014
    Beans
    Hidden!

    Ubuntu is not using swap space

    Instead of using a swap partition, I've always used a swap file (Debian, OpenSUSE, Slackware, Ubuntu) and I've never had problems. But I've just installed Ubuntu 14.04 LTS, I created a swap file as usual (using this procedure), and it seems Ubuntu is not using my swap space available:

    Code:
    free -m             total       used       free     shared    buffers     cached
    Mem:          7882       7722        159        321        748       2178
    -/+ buffers/cache:       4795       3086
    Swap:        10239          0      10239
    This is my /etc/fstab in the part concerning my swap file:
    Code:
    /root/swapfile none swap sw 0 0
    It's currently almost out of memory, but not a single byte of the swap space is being used. The system is slow and it feels clumsy to use. What's wrong? Why isnt' Ubuntu using the swap space availabe and how do I fix it?
    Last edited by Novitk; March 22nd, 2015 at 07:12 AM.

  2. #2
    Join Date
    Aug 2009
    Location
    Makati City, Philippines
    Beans
    2,269
    Distro
    Xubuntu 16.04 Xenial Xerus

    Re: Ubuntu is not using swap space

    Not using swap is a good thing since swap is way slower than RAM.
    And your computer is not running low on memory. The second line show the real memory usage and the first line show memory usage with cache.

    I think you should "load" you computer more, maybe open more programs, open firefox with 20 tabs and leave for half a day and you're sure to use some swap space.

  3. #3
    Join Date
    Nov 2011
    Beans
    2,336
    Distro
    Ubuntu

    Re: Ubuntu is not using swap space

    Swap is used when something makes a memory allocation request that cannot be met from free, unallocated, RAM. In that case, a chunk of allocated RAM is written to swap.

    I've never used a swap *file*, but, perhaps, your system seems slow because using a file for swap *is* slower than using a partition.

  4. #4
    Join Date
    Jun 2010
    Location
    London, England
    Beans
    Hidden!
    Distro
    Ubuntu Development Release

    Re: Ubuntu is not using swap space

    You have as twice as much cache memory as i have RAM and it seems that I am getting a better user experience than you. Could the problem be the video driver?

    An OS will take as much memory as is available. And that is as it should be. The important part is the way it uses memory. What we see as "used" memory is actually memory claimed by the OS for allocation for any task that the user instructs the OS to do. I think that we will find that "used" memory also includes "cached" memory. Add "used" to "cache" and the sum is greater than "total."

    Regards.
    It is a machine. It is more stupid than we are. It will not stop us from doing stupid things.
    Ubuntu user #33,200. Linux user #530,530


  5. #5
    Join Date
    Nov 2011
    Beans
    2,336
    Distro
    Ubuntu

    Re: Ubuntu is not using swap space

    If you open a terminal, leave it open, and run
    Code:
    vmstat 3 100
    you'll see something like this:
    Code:
    vmstat 3 100
    procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
     r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
     1  0      0 29593708  68932 1064880    0    0    72    65   52  193  1  0 98  1  0
     0  0      0 29593192  68932 1064896    0    0     0     0   93  148  0  0 100  0  0
     0  1      0 29598064  68940 1060016    0    0     0    29  103  127  0  0 100  0  0
    This displays a running look at how swap is being used. The 'so' column shows the amount of memory written out to swap and the 'si' column shows the amount being read into memory from swap. (Both zero here; the columns are a bit askew.)

    Dunno if this works when a swap file is used rather than the expected partition.

  6. #6
    Join Date
    Jun 2014
    Beans
    Hidden!

    Re: Ubuntu is not using swap space

    Swap is not being used and I think it's I misunderstood the output. I had indeed a lot of free memory. I was with VirtualBox running Windows XP and I thought the problem was a lack of memory, but I guess I was wrong. My swap file is not being used and it probably shouldn't be used anyway, since I have so much free memory. Thanks to clarify things for me, guys!

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •