Linux cached memory: Over 85% of cached memory and using swap

91

Solution 1

No! In your example post, effectively nothing is used for swap. You're using 92k (or 132k in the second screenshot) of swap which is incidental and trivial.

Cached memory is free memory that has been filled with the contents of blocks on disk. It will be vacated as soon as the space is needed by anything else. This is a good thing that enhances performance.

Compare your question with Server refuses to use swap partition.

As for why a server might swap data instead of releasing cache, it may be the case that your cached data was being read much more than your data stored in memory. Programs sometimes have pages that they rarely, if ever, visit. That space is better utilized by caching.

The vm.swappiness setting (also modifiable live through /proc...) will affect that, but spend some time looking closely at what's going on before adjusting it, particularly with your swap in / out counters. sar and atop are useful tools for this.

Solution 2

Try to add vm.swappiness = 0 to /etc/sysctl.conf and run sysctl -p then, this will instruct kernel to release memory occupied by the file cache more aggressively if a user application requires a memory region from kernel.

Share:
91

Related videos on Youtube

Cappittall
Author by

Cappittall

Updated on September 18, 2022

Comments

  • Cappittall
    Cappittall over 1 year

    starting index html and all static files works goo. I can deploy static files but for php, first I met 404 eror, but after all I changed the app.yaml as:

    runtime: php55
    api_version: 2
    threadsafe: true
    
    handlers:
    - url: /(.*).php 
      script: \1.php
    
    - url: /
      static_files: www/index.html
      upload: www/index.html
    
    - url: /(.*)
      static_files: www/\1
      upload: www/(.*)
    

    Now, some php works ok. but this time some php files giving Post 500 error. Any idea ?

    a part of deploy log file:

     "GET /images/Egg-heart-for-slider.png HTTP/1.1" 204
     "POST /vendor/sms.php HTTP/1.1" 500
     "POST /vendor/mail.php HTTP/1.1" 200
     "POST / HTTP/1.1" 200
     "GET /js/jquery.scrollex.min.js HTTP/1.1" 204
     "GET /js/jquery.scrolly.min.js HTTP/1.1" 204
     "GET /js/util/jquery.inputmask.js HTTP/1.1" 204
     "GET /js/util/inputmask.extensions.js HTTP/1.1" 204
     "GET /js/jquery.min.js HTTP/1.1" 204
     "GET /js/skel.min.js HTTP/1.1" 204
     "GET /js/util.js HTTP/1.1" 204
     "GET /js/main.js HTTP/1.1" 204
     "GET /js/util/inputmask.js HTTP/1.1" 204
     "GET /js/jstulumbal.js HTTP/1.1" 204
     "GET /js/kkvalidate.js HTTP/1.1" 204
    
    • David Schwartz
      David Schwartz almost 10 years
      The idea that swap makes a system slow is entirely false. Your system will use swap only when it is beneficial to do so.
  • Kuf
    Kuf over 11 years
    Thanks for the fast answer, I will test it when the server will be idle.
  • Kuf
    Kuf over 11 years
    Thanks, after lot's of testing we found that you were right. Many thanks for your input!