Announcement

Collapse
No announcement yet.

How do I reclaim swap memory?

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How do I reclaim swap memory?

    Is there some kind of utility or technique for reclaiming memory? (No, I'm not forgetful - lol) I'm pretty sure the problem is with Firefox but it is getting severe. It was always pretty bad, but the new FF is worse. After being used for a week or two, my swap memory is still going up and is now at 598,872KB! What that does is introduce delays - sometimes long ones. Closing and reopening FF makes it fast again for a little while, but it doesn't reclaim the swap. I like to use FF for some things so I don't really want to move all my browsing over to other browsers. I also don't like having to close FF and want to avoid rebooting at all costs. All suggestions welcome.


    #2
    Re: How do I reclaim swap memory?

    I haven't had a problem with this for a while but maybe this will help:
    http://blog.pavlov.net/2008/03/11/fi...-memory-usage/
    HP Pavilion dv6 core i7 (Main)
    4 GB Ram
    Kubuntu 18.10

    Comment


      #3
      Re: How do I reclaim swap memory?

      To have swap memory leaks build up like that I am assuming that you are leaving your computer on for "a week or two". If so, does rebooting recover the your full swap?

      It could be add-ons or extensions causing the problem. Try disabling all your add-ons and extensions, then turn then one one, with sufficient time between to be able to keep an eye on the swap space and see if the last item turned on is the problem.
      "A nation that is afraid to let its people judge the truth and falsehood in an open market is a nation that is afraid of its people.”
      – John F. Kennedy, February 26, 1962.

      Comment


        #4
        Re: How do I reclaim swap memory?

        Originally posted by Ole Juul
        Is there some kind of utility or technique for reclaiming memory? (No, I'm not forgetful - lol) I'm pretty sure the problem is with Firefox but it is getting severe. It was always pretty bad, but the new FF is worse. After being used for a week or two, my swap memory is still going up and is now at 598,872KB! What that does is introduce delays - sometimes long ones. Closing and reopening FF makes it fast again for a little while, but it doesn't reclaim the swap. I like to use FF for some things so I don't really want to move all my browsing over to other browsers. I also don't like having to close FF and want to avoid rebooting at all costs. All suggestions welcome.

        It honestly sounds like a memory leak. You can change how the kernel swaps memory with the kernel parameter 'vm.swappiness'. The default setting is 60, but I prefer 10 1 or 0 depending on workload. You can set it in /etc/sysctl.conf and issue a 'sudo sysctl -p' to enable it.

        0 means don't swap unless absolutely necessary
        1 is slightly less aggressive in keeping memory resident
        10 will page out memory, but far less often than the default of 60

        To pull all memory from swap back to RAM you can use:

        sudo swapoff -a; sudo swapon -a

        If you don't have enough available physical memory to read the entire content of swap you could trigger OOM killer which would start to destroy processes to keep the system running.

        You can calculate how much memory you have by looking at the output of free. Add free + buffers + cached and that is what is really available to the system.

        You can also drop all of your cache memory with the following:

        echo 1 | sudo tee /proc/sys/vm/drop_caches

        You'll see an immediate change in the output of free.
        Don't blame me for being smarter than you, that's your parent's fault.

        Comment


          #5
          Re: How do I reclaim swap memory?

          I don't know how much RAM you have, but the traditional size of the swap file was twice the RAM. However, with current distros many are installed without any swap file at all. I have 2.8GB of available memory and I have NEVER seen my swap file being used. It always stays as 0 bytes usage.
          "A nation that is afraid to let its people judge the truth and falsehood in an open market is a nation that is afraid of its people.”
          – John F. Kennedy, February 26, 1962.

          Comment


            #6
            Re: How do I reclaim swap memory?

            @Fintan: Thanks for the link, that does give some insight.

            @GreyGeek: Yes, I leave my computer on indefinitely and only reboot if there is a problem. It used to be up for months on end but this has changed that. Rebooting does recover the full swap but it grows again. Until this problem came up I would NEVER see ANY swap being used which I assume is how it should be on a contemporary Linux system. I have 3GB of RAM and the swap partition is apprx. 2.2GB. When I set up the partitions some years back, I didn't see any reason to use a lot of space for that and as you say, "with current distros many are installed without any swap file at all". Anyway, I think you may be right about addons. I have recently installed several and from the article that Fintan suggested, I see that addons are particularly suspect. I will disable them systematically and see what happens.

            @zlow: Thankyou for the many suggestions. I will have a look at all of them. Right now, I just killed FF and then restarted. It came back with an amazing 700K swap! Then I did both sudo swapoff -a and sudo swapon -a. The result was that it came back with only 38K. I also did "echo 1 | sudo tee /proc/sys/vm/drop_caches" but there was no change in the output of free so I put the file back to 0.

            Thanks all for your input. I will work on it and report back.


            Edit: I just realized that I was missing some zeros. 700K and 38K should be MB!






            Comment


              #7
              Re: How do I reclaim swap memory?

              I have disabled all addons in Firefox and the problem persists. Swap is brought to zero by swapon/swapoff but is starts growing in a few minutes. This is really annoying.

              I had assumed it was FF, because it started getting worse after I upgraded it, but there is another Gecko-based browser which I guess could interact. Of course it varies a bit, but here is what else is always running:

              Galeon (Gecko-based)
              Ephiphany (WebKit-based)
              Opera
              Chromium
              Dillo
              5 terminals

              This may seem like a lot, but that's how I do it.

              HOWEVER, I am working on this as I am writing AND:

              I just realized that Chromium is relatively new on here and despite it only having 7 windows open, I just decided to kill it and see what happened. Magically 1GB of memory came back! What is even more interesting is that when I brought it back (same 7 windows) it didn't grab much memory. Firefox, by the way, currently has 28 windows open.

              I guess these programs work in radically different ways because Firefox only has 2 entries in my process table, whereas Chromium has 17. I'm starting to think that despite it being fast and seemingly stable, (up more than two weeks until now) it is perhaps still broken.

              So, Chromium may be where the problem lies. If something else relevant to this thread pops up, I will post back. Meanwhile, thanks again for everybody's suggestions.



              Comment


                #8
                Re: How do I reclaim swap memory?

                Ah, the old chromium memory hog ploy

                Have a look here:
                http://ubuntuforums.org/showthread.php?t=1472790&page=2
                HP Pavilion dv6 core i7 (Main)
                4 GB Ram
                Kubuntu 18.10

                Comment


                  #9
                  Re: How do I reclaim swap memory?

                  Testing the apps if the add-ons weren't the culprit was my next suggestion but you beat me to it! 8)
                  "A nation that is afraid to let its people judge the truth and falsehood in an open market is a nation that is afraid of its people.”
                  – John F. Kennedy, February 26, 1962.

                  Comment

                  Working...
                  X