How does opening a file descriptor effect memory

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











up vote
0
down vote

favorite












Let’s say I have a 250MB file that I read from by opening a file descriptor. Does the entire file get dumped into memory and stay there until I close the file descriptor?

How does that differ from parsing data from the same file with a command like sed, grep, or awk?







share|improve this question
























    up vote
    0
    down vote

    favorite












    Let’s say I have a 250MB file that I read from by opening a file descriptor. Does the entire file get dumped into memory and stay there until I close the file descriptor?

    How does that differ from parsing data from the same file with a command like sed, grep, or awk?







    share|improve this question






















      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      Let’s say I have a 250MB file that I read from by opening a file descriptor. Does the entire file get dumped into memory and stay there until I close the file descriptor?

      How does that differ from parsing data from the same file with a command like sed, grep, or awk?







      share|improve this question












      Let’s say I have a 250MB file that I read from by opening a file descriptor. Does the entire file get dumped into memory and stay there until I close the file descriptor?

      How does that differ from parsing data from the same file with a command like sed, grep, or awk?









      share|improve this question











      share|improve this question




      share|improve this question










      asked Dec 25 '17 at 2:57









      EnterUserNameHere

      4318




      4318




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          2
          down vote



          accepted










          The kernel will buffer the file in memory according to the kernel policy and memory demand situation. The whole file may end up in memory, and it will possibly stay in memory even after the file descriptor is closed until the buffers need to be reused, so if you run the same application with the same file again directly afterwards, it will be much faster. Or only parts may end up in memory, read after each other.



          All applications behave the same in that respect, it doesn't matter what the application is. Though there are different ways of opening a file, and this may affect details of how everything works.






          share|improve this answer




















            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: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            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%2f412880%2fhow-does-opening-a-file-descriptor-effect-memory%23new-answer', 'question_page');

            );

            Post as a guest






























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            2
            down vote



            accepted










            The kernel will buffer the file in memory according to the kernel policy and memory demand situation. The whole file may end up in memory, and it will possibly stay in memory even after the file descriptor is closed until the buffers need to be reused, so if you run the same application with the same file again directly afterwards, it will be much faster. Or only parts may end up in memory, read after each other.



            All applications behave the same in that respect, it doesn't matter what the application is. Though there are different ways of opening a file, and this may affect details of how everything works.






            share|improve this answer
























              up vote
              2
              down vote



              accepted










              The kernel will buffer the file in memory according to the kernel policy and memory demand situation. The whole file may end up in memory, and it will possibly stay in memory even after the file descriptor is closed until the buffers need to be reused, so if you run the same application with the same file again directly afterwards, it will be much faster. Or only parts may end up in memory, read after each other.



              All applications behave the same in that respect, it doesn't matter what the application is. Though there are different ways of opening a file, and this may affect details of how everything works.






              share|improve this answer






















                up vote
                2
                down vote



                accepted







                up vote
                2
                down vote



                accepted






                The kernel will buffer the file in memory according to the kernel policy and memory demand situation. The whole file may end up in memory, and it will possibly stay in memory even after the file descriptor is closed until the buffers need to be reused, so if you run the same application with the same file again directly afterwards, it will be much faster. Or only parts may end up in memory, read after each other.



                All applications behave the same in that respect, it doesn't matter what the application is. Though there are different ways of opening a file, and this may affect details of how everything works.






                share|improve this answer












                The kernel will buffer the file in memory according to the kernel policy and memory demand situation. The whole file may end up in memory, and it will possibly stay in memory even after the file descriptor is closed until the buffers need to be reused, so if you run the same application with the same file again directly afterwards, it will be much faster. Or only parts may end up in memory, read after each other.



                All applications behave the same in that respect, it doesn't matter what the application is. Though there are different ways of opening a file, and this may affect details of how everything works.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Dec 25 '17 at 8:54









                dirkt

                14.1k2931




                14.1k2931






















                     

                    draft saved


                    draft discarded


























                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f412880%2fhow-does-opening-a-file-descriptor-effect-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?

                    Bahrain

                    Postfix configuration issue with fips on centos 7; mailgun relay