Does sync command remove the dirty cache in the memory?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
2
down vote

favorite












I am aware that sync command flushes the dirty cache into disk. I have run free command first, then sync, and then free again. The result of latter free command shows more free memory available than the former one.



Does this mean that the dirty caches are removed from memory when performing sync? Can anybody give me a more solid proof?










share|improve this question























  • Related: How do you empty the buffers and cache on a Linux system?
    – slm♦
    Aug 27 '13 at 6:54















up vote
2
down vote

favorite












I am aware that sync command flushes the dirty cache into disk. I have run free command first, then sync, and then free again. The result of latter free command shows more free memory available than the former one.



Does this mean that the dirty caches are removed from memory when performing sync? Can anybody give me a more solid proof?










share|improve this question























  • Related: How do you empty the buffers and cache on a Linux system?
    – slm♦
    Aug 27 '13 at 6:54













up vote
2
down vote

favorite









up vote
2
down vote

favorite











I am aware that sync command flushes the dirty cache into disk. I have run free command first, then sync, and then free again. The result of latter free command shows more free memory available than the former one.



Does this mean that the dirty caches are removed from memory when performing sync? Can anybody give me a more solid proof?










share|improve this question















I am aware that sync command flushes the dirty cache into disk. I have run free command first, then sync, and then free again. The result of latter free command shows more free memory available than the former one.



Does this mean that the dirty caches are removed from memory when performing sync? Can anybody give me a more solid proof?







linux memory synchronization






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Aug 27 '13 at 4:24









Anthon

59.5k17100162




59.5k17100162










asked Aug 27 '13 at 3:51









Shasha.Zhu

112




112











  • Related: How do you empty the buffers and cache on a Linux system?
    – slm♦
    Aug 27 '13 at 6:54

















  • Related: How do you empty the buffers and cache on a Linux system?
    – slm♦
    Aug 27 '13 at 6:54
















Related: How do you empty the buffers and cache on a Linux system?
– slm♦
Aug 27 '13 at 6:54





Related: How do you empty the buffers and cache on a Linux system?
– slm♦
Aug 27 '13 at 6:54











3 Answers
3






active

oldest

votes

















up vote
1
down vote













No, It don't. I checked it myself many times, but don't worry, Linux kernel takes care of your precious memory very smartly.
read Content cached in RAM while writing to disk - Linux
and http://linuxatemyram.com






share|improve this answer





























    up vote
    0
    down vote













    This will cause the kernel to drop clean caches, dentries and inodes from memory, causing that memory to become free.



    To free pagecache:



    echo 1 > /proc/sys/vm/drop_caches


    To free dentries and inodes:



    echo 2 > /proc/sys/vm/drop_caches


    To free pagecache, dentries and inodes:



    echo 3 > /proc/sys/vm/drop_caches


    As this is a non-destructive operation, and dirty objects are not freeable, the user should run "sync" first in order to make sure all cached objects are freed.






    share|improve this answer




















    • Source: kernel.org/doc/Documentation/sysctl/vm.txt
      – Smith John
      Aug 27 '13 at 5:59

















    up vote
    0
    down vote













    They are not :-). Here is solid proof:



    $ dd if=/dev/zero of=test bs=1M count=100
    100+0 records in
    100+0 records out
    104857600 bytes (105 MB, 100 MiB) copied, 0.409106 s, 256 MB/s
    $ sync
    $ time cat test > /dev/null

    real 0m0.027s
    user 0m0.000s
    sys 0m0.026s


    The data was still cached after sync. You can tell it was cached by looking at the time to read the file. (I have a spinning hard drive, max read speed is around 100MB/s). Compare this to the combination of sync and drop_caches:



    $ sync
    $ echo 1 | sudo tee /proc/sys/vm/drop_caches
    1
    $ time cat test > /dev/null

    real 0m1.030s
    user 0m0.001s
    sys 0m0.073s




    share




















      Your Answer








      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "106"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      convertImagesToLinks: false,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













       

      draft saved


      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f88314%2fdoes-sync-command-remove-the-dirty-cache-in-the-memory%23new-answer', 'question_page');

      );

      Post as a guest






























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      1
      down vote













      No, It don't. I checked it myself many times, but don't worry, Linux kernel takes care of your precious memory very smartly.
      read Content cached in RAM while writing to disk - Linux
      and http://linuxatemyram.com






      share|improve this answer


























        up vote
        1
        down vote













        No, It don't. I checked it myself many times, but don't worry, Linux kernel takes care of your precious memory very smartly.
        read Content cached in RAM while writing to disk - Linux
        and http://linuxatemyram.com






        share|improve this answer
























          up vote
          1
          down vote










          up vote
          1
          down vote









          No, It don't. I checked it myself many times, but don't worry, Linux kernel takes care of your precious memory very smartly.
          read Content cached in RAM while writing to disk - Linux
          and http://linuxatemyram.com






          share|improve this answer














          No, It don't. I checked it myself many times, but don't worry, Linux kernel takes care of your precious memory very smartly.
          read Content cached in RAM while writing to disk - Linux
          and http://linuxatemyram.com







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Apr 13 '17 at 12:36









          Community♦

          1




          1










          answered Jun 22 '15 at 6:06









          Arnab

          743619




          743619






















              up vote
              0
              down vote













              This will cause the kernel to drop clean caches, dentries and inodes from memory, causing that memory to become free.



              To free pagecache:



              echo 1 > /proc/sys/vm/drop_caches


              To free dentries and inodes:



              echo 2 > /proc/sys/vm/drop_caches


              To free pagecache, dentries and inodes:



              echo 3 > /proc/sys/vm/drop_caches


              As this is a non-destructive operation, and dirty objects are not freeable, the user should run "sync" first in order to make sure all cached objects are freed.






              share|improve this answer




















              • Source: kernel.org/doc/Documentation/sysctl/vm.txt
                – Smith John
                Aug 27 '13 at 5:59














              up vote
              0
              down vote













              This will cause the kernel to drop clean caches, dentries and inodes from memory, causing that memory to become free.



              To free pagecache:



              echo 1 > /proc/sys/vm/drop_caches


              To free dentries and inodes:



              echo 2 > /proc/sys/vm/drop_caches


              To free pagecache, dentries and inodes:



              echo 3 > /proc/sys/vm/drop_caches


              As this is a non-destructive operation, and dirty objects are not freeable, the user should run "sync" first in order to make sure all cached objects are freed.






              share|improve this answer




















              • Source: kernel.org/doc/Documentation/sysctl/vm.txt
                – Smith John
                Aug 27 '13 at 5:59












              up vote
              0
              down vote










              up vote
              0
              down vote









              This will cause the kernel to drop clean caches, dentries and inodes from memory, causing that memory to become free.



              To free pagecache:



              echo 1 > /proc/sys/vm/drop_caches


              To free dentries and inodes:



              echo 2 > /proc/sys/vm/drop_caches


              To free pagecache, dentries and inodes:



              echo 3 > /proc/sys/vm/drop_caches


              As this is a non-destructive operation, and dirty objects are not freeable, the user should run "sync" first in order to make sure all cached objects are freed.






              share|improve this answer












              This will cause the kernel to drop clean caches, dentries and inodes from memory, causing that memory to become free.



              To free pagecache:



              echo 1 > /proc/sys/vm/drop_caches


              To free dentries and inodes:



              echo 2 > /proc/sys/vm/drop_caches


              To free pagecache, dentries and inodes:



              echo 3 > /proc/sys/vm/drop_caches


              As this is a non-destructive operation, and dirty objects are not freeable, the user should run "sync" first in order to make sure all cached objects are freed.







              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered Aug 27 '13 at 5:50









              Gopal Singh Dagur

              1




              1











              • Source: kernel.org/doc/Documentation/sysctl/vm.txt
                – Smith John
                Aug 27 '13 at 5:59
















              • Source: kernel.org/doc/Documentation/sysctl/vm.txt
                – Smith John
                Aug 27 '13 at 5:59















              Source: kernel.org/doc/Documentation/sysctl/vm.txt
              – Smith John
              Aug 27 '13 at 5:59




              Source: kernel.org/doc/Documentation/sysctl/vm.txt
              – Smith John
              Aug 27 '13 at 5:59










              up vote
              0
              down vote













              They are not :-). Here is solid proof:



              $ dd if=/dev/zero of=test bs=1M count=100
              100+0 records in
              100+0 records out
              104857600 bytes (105 MB, 100 MiB) copied, 0.409106 s, 256 MB/s
              $ sync
              $ time cat test > /dev/null

              real 0m0.027s
              user 0m0.000s
              sys 0m0.026s


              The data was still cached after sync. You can tell it was cached by looking at the time to read the file. (I have a spinning hard drive, max read speed is around 100MB/s). Compare this to the combination of sync and drop_caches:



              $ sync
              $ echo 1 | sudo tee /proc/sys/vm/drop_caches
              1
              $ time cat test > /dev/null

              real 0m1.030s
              user 0m0.001s
              sys 0m0.073s




              share
























                up vote
                0
                down vote













                They are not :-). Here is solid proof:



                $ dd if=/dev/zero of=test bs=1M count=100
                100+0 records in
                100+0 records out
                104857600 bytes (105 MB, 100 MiB) copied, 0.409106 s, 256 MB/s
                $ sync
                $ time cat test > /dev/null

                real 0m0.027s
                user 0m0.000s
                sys 0m0.026s


                The data was still cached after sync. You can tell it was cached by looking at the time to read the file. (I have a spinning hard drive, max read speed is around 100MB/s). Compare this to the combination of sync and drop_caches:



                $ sync
                $ echo 1 | sudo tee /proc/sys/vm/drop_caches
                1
                $ time cat test > /dev/null

                real 0m1.030s
                user 0m0.001s
                sys 0m0.073s




                share






















                  up vote
                  0
                  down vote










                  up vote
                  0
                  down vote









                  They are not :-). Here is solid proof:



                  $ dd if=/dev/zero of=test bs=1M count=100
                  100+0 records in
                  100+0 records out
                  104857600 bytes (105 MB, 100 MiB) copied, 0.409106 s, 256 MB/s
                  $ sync
                  $ time cat test > /dev/null

                  real 0m0.027s
                  user 0m0.000s
                  sys 0m0.026s


                  The data was still cached after sync. You can tell it was cached by looking at the time to read the file. (I have a spinning hard drive, max read speed is around 100MB/s). Compare this to the combination of sync and drop_caches:



                  $ sync
                  $ echo 1 | sudo tee /proc/sys/vm/drop_caches
                  1
                  $ time cat test > /dev/null

                  real 0m1.030s
                  user 0m0.001s
                  sys 0m0.073s




                  share












                  They are not :-). Here is solid proof:



                  $ dd if=/dev/zero of=test bs=1M count=100
                  100+0 records in
                  100+0 records out
                  104857600 bytes (105 MB, 100 MiB) copied, 0.409106 s, 256 MB/s
                  $ sync
                  $ time cat test > /dev/null

                  real 0m0.027s
                  user 0m0.000s
                  sys 0m0.026s


                  The data was still cached after sync. You can tell it was cached by looking at the time to read the file. (I have a spinning hard drive, max read speed is around 100MB/s). Compare this to the combination of sync and drop_caches:



                  $ sync
                  $ echo 1 | sudo tee /proc/sys/vm/drop_caches
                  1
                  $ time cat test > /dev/null

                  real 0m1.030s
                  user 0m0.001s
                  sys 0m0.073s





                  share











                  share


                  share










                  answered 6 mins ago









                  sourcejedi

                  21.4k43395




                  21.4k43395



























                       

                      draft saved


                      draft discarded















































                       


                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f88314%2fdoes-sync-command-remove-the-dirty-cache-in-the-memory%23new-answer', 'question_page');

                      );

                      Post as a guest













































































                      Popular posts from this blog

                      How to check contact read email or not when send email to Individual?

                      Displaying single band from multi-band raster using QGIS

                      How many registers does an x86_64 CPU actually have?