Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Cache Memory NEVER Released

Hybrid View

  1. #1
    Join Date
    Mar 2006
    Beans
    16

    Cache Memory NEVER Released

    Hi,

    I'm having a strange problem with all my computers that are running ubuntu...
    After I do a lot of operations with files (like copy, compilation, etc), anything that makes use of the cache, makes the computer ran out of memory!
    Well, I do not get any error! It will just not let me open any new applications...

    Here an example that just happen:
    I did compile a big project with Maven2 which downloaded a lot of files... Right now I get that my computer is using 72% as cache and 22% by programs... (By the way, I've 3GB of memory in this machine).

    All seems fine, at least with the open applications like firefox that I'm using to write this new thread. The problem now is that I can't open any new applications, and that includes a simple terminal window!
    Nothing that is not in memory already will start!

    Does anyone knows for how long the cache system keeps the allocated memory?
    Is there a way to make it release it back?

    The compilation has ended for quite some time, all the files have already been written to the disc and I still don't have my memory back...
    The only solution is to restart the machine.

    I'm having the same problem with other machines that are running ubuntu too. All with 8.04 with the latest updates...

    Any suggestions?
    Any know Bugs???

    BTW, I've been "googling" and searching in the forum but I did not find anything like it...

    Regards,

    /Carlo

  2. #2
    Join Date
    Mar 2006
    Beans
    16

    Re: Cache Memory NEVER Released

    By the way, I ran free -m in a terminal window that was open before I ran out of memory...

    free -m
    total used free shared buffers cached
    Mem: 3026 2809 217 0 290 1785
    -/+ buffers/cache: 733 2293
    Swap: 3922 0 3921

  3. #3
    Join Date
    Aug 2006
    Beans
    9

    Re: Cache Memory NEVER Released

    That's true. I think Ubuntu should release some cache in a timely fashion, to avoid using swap.

    EDIT: by the way, to free up cache memory, run this command:

    sudo sh -c "sync && echo 3 > /proc/sys/vm/drop_caches"
    Last edited by rebeldevel; July 2nd, 2008 at 03:15 PM.

  4. #4
    Join Date
    Apr 2008
    Beans
    76
    Distro
    Ubuntu 8.04 Hardy Heron

    Re: Cache Memory NEVER Released

    Quote Originally Posted by rebeldevel View Post
    That's true. I think Ubuntu should release some cache in a timely fashion, to avoid using swap.

    EDIT: by the way, to free up cache memory, run this command:

    sudo sh -c "sync && echo 3 > /proc/sys/vm/drop_caches"
    Awesome, I've been looking for this.
    I just made a launcher for it on the desktop :]
    Many thanks.

  5. #5
    Join Date
    Jan 2007
    Location
    $here ? $here : $there
    Beans
    3,717
    Distro
    Ubuntu 8.04 Hardy Heron

    Re: Cache Memory NEVER Released

    The only thing dropping the cache will do is make your system a lot less responsive. If you want to avoid using swap while retaining the cache, add the following to /etc/sysctl.conf:

    Code:
    vm.swappiness = 1
    Then run:

    Code:
    sudo sysctl -p
    That change will stick over reboots.
    Don't try to make something "fast" until you are able to quantify "slow".

  6. #6
    Join Date
    Mar 2006
    Beans
    16

    Re: Cache Memory NEVER Released

    Quote Originally Posted by rebeldevel View Post
    That's true. I think Ubuntu should release some cache in a timely fashion, to avoid using swap.

    EDIT: by the way, to free up cache memory, run this command:

    sudo sh -c "sync && echo 3 > /proc/sys/vm/drop_caches"

    Thanks!
    The command you sent did the trick!
    ( sudo sh -c "sync && echo 3 > /proc/sys/vm/drop_caches" )

    The scenario this time was that I just downloaded 2 iso files (LinuxMCE) and were using the computer normally to write the CDs, surfing and so on... The cache filled up and I was left without memory to open any new applications...

    Kernel automatically releasing cache?
    Nop, the swap wasn't even used and it did not released anything from the cache...
    About future use of the cache:
    Yes, I do want to use the cache now and than but in this scenario cache wasn't important...

  7. #7
    Join Date
    Jan 2007
    Location
    $here ? $here : $there
    Beans
    3,717
    Distro
    Ubuntu 8.04 Hardy Heron

    Re: Cache Memory NEVER Released

    Quote Originally Posted by maraschin View Post
    Thanks!
    The command you sent did the trick!
    ( sudo sh -c "sync && echo 3 > /proc/sys/vm/drop_caches" )

    The scenario this time was that I just downloaded 2 iso files (LinuxMCE) and were using the computer normally to write the CDs, surfing and so on... The cache filled up and I was left without memory to open any new applications...

    Kernel automatically releasing cache?
    Nop, the swap wasn't even used and it did not released anything from the cache...
    About future use of the cache:
    Yes, I do want to use the cache now and than but in this scenario cache wasn't important...
    Unless you've done something very odd to your machine, it's simply not possible that the cache is causing this. My guess is that nearly every person posting on this forum would find that if they did a "free -m" they would see that the cache is taking all available memory and yet none of them are having the problems you are describing. Something else must be going on. You are certainly free to run your machine however you see fit, but, by constantly dropping the cache, you are doing yourself a disservice.
    Don't try to make something "fast" until you are able to quantify "slow".

  8. #8
    Join Date
    Nov 2008
    Beans
    1

    Re: Cache Memory NEVER Released

    I have the same problem with OpenSUSE 11.0

  9. #9
    Join Date
    Mar 2006
    Beans
    16

    Re: Cache Memory NEVER Released

    I guess I did not google enough...

    I found a "possible" solution...

    http://www.faqs.org/docs/linux_admin/buffer-cache.html

    The command sync may be the answer but I could not replicate it yet in my tests... it could be that update had crashed but I'm not sure.

    I tried to fill up the cache and clean with sync and it seems to work fine. But even when I'd the cache full I still could open applications so I'll have to wait to try this one out when I get the same problem again and see if isn't another problem...

  10. #10
    Join Date
    Jan 2007
    Location
    $here ? $here : $there
    Beans
    3,717
    Distro
    Ubuntu 8.04 Hardy Heron

    Re: Cache Memory NEVER Released

    This can't be a problem with the cache. Having your otherwise unused memory filled by the cache is a very good thing and dramatically improves system performance. If your applications need memory, linux will drop pages from the cache to make room for your applications. I suspect something else is going on here.
    Don't try to make something "fast" until you are able to quantify "slow".

Page 1 of 2 12 LastLast

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
  •