How to reduce free memory to certain number for specific time durationHow to configure ubuntu for lightweight low-memory usage?Memory usage doesn't add up over timeDid Ubuntu 12.04 server really eat my RAM?Out of Memory IssueUbuntu 18.04 running slow with 4GB RAM

How do critical hits work with static monster damage?

Isn't any conversation with the US president quid-pro-quo?

Elevator design implementation in C++

Is the genre 'fantasy' still fantasy without magic?

Beautiful planar geometry theorems not encountered in high school

What is the name of the fallacy involving white and black swans?

How can I improve combat so my players don't always use the strategy of collectively focusing fire on one enemy at a time until it's dead?

Are there any dishes that can only be cooked with a microwave?

Stack data structure in python 3

Does toddler keep hands around private parts?

Can I use pavers as a cheap solution to stop rain water erosion?

How to spot dust on lens quickly while doing a shoot outdoors?

How can one "treat writing as a job" even though it doesn't pay?

Can it be viewed as a negative for PhD applications in the US if I have children?

Why has no one requested the tape of the Trump/Ukraine call?

Where does the budget surplus of a conference go?

Is it a mistake to use a password that has previously been used (by anyone ever)?

Is "montäglich" commonly used?

What is the name of this landform?

How to break a equation with a single "summation symbol (sum) " common?

Stalemate situation with all pieces on the board

Surmounting set-theoretical difficulties in algebraic geometry

How to deal with lack of advantages for a character starting at low point total?

how can traditional forms of magic compete against demon magic?



How to reduce free memory to certain number for specific time duration


How to configure ubuntu for lightweight low-memory usage?Memory usage doesn't add up over timeDid Ubuntu 12.04 server really eat my RAM?Out of Memory IssueUbuntu 18.04 running slow with 4GB RAM






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty
margin-bottom:0;









1


















I want to stress memory for certain time duration. I am checking memory usage with vmstat -s and using tail /dev/zero command but tail /dev/zero times out in about 60s and it fills out memory randomly. I want to have available free memory 5% for 180 seconds.










share|improve this question































    1


















    I want to stress memory for certain time duration. I am checking memory usage with vmstat -s and using tail /dev/zero command but tail /dev/zero times out in about 60s and it fills out memory randomly. I want to have available free memory 5% for 180 seconds.










    share|improve this question



























      1













      1









      1








      I want to stress memory for certain time duration. I am checking memory usage with vmstat -s and using tail /dev/zero command but tail /dev/zero times out in about 60s and it fills out memory randomly. I want to have available free memory 5% for 180 seconds.










      share|improve this question














      I want to stress memory for certain time duration. I am checking memory usage with vmstat -s and using tail /dev/zero command but tail /dev/zero times out in about 60s and it fills out memory randomly. I want to have available free memory 5% for 180 seconds.







      ram memory-usage stress-testing






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Sep 5 at 19:40









      beginner_userbeginner_user

      454 bronze badges




      454 bronze badges























          1 Answer
          1






          active

          oldest

          votes


















          0



















          One could use the kernel trace buffer as a way to reduce available memory left for the system and/or user. Example, using my system with 16 gigabytes and 8 CPUs:



          First flush memory, giving our starting point (note that I am running as root):



          root@s15:/home/doug/temp-k-git/linux# sync
          root@s15:/home/doug/temp-k-git/linux# echo 3 > /proc/sys/vm/drop_caches
          root@s15:/home/doug/temp-k-git/linux# free -m
          total used free shared buff/cache available
          Mem: 15719 88 15472 1 159 15343
          Swap: 16085 35 16050


          Now, calculate and allocate the memory to the kernel trace buffer: 5% of 15719 megabytyes is 786 megabytes. Starting from 15472 megabytyes, Then 14686 megabyytes need to be used. The kernel trace buffer is per CPU, in my case 8 CPUs, so 1835 megabytes per CPU. Allocate:



          root@s15:/home/doug/temp-k-git/linux# echo 1835000 > /sys/kernel/debug/tracing/buffer_size_kb


          And check it:



          root@s15:/home/doug/temp-k-git/linux# free -m
          total used free shared buff/cache available
          Mem: 15719 14476 858 1 385 730
          Swap: 16085 35 16050


          You can observe that it resulted in 5.46% of memory still available (tweek the allocation, if needed). Once you have done whatever testing, then you can de-allocate the kernel trace buffer with (0 does not work):



          root@s15:/home/doug/temp-k-git/linux# echo 1 > /sys/kernel/debug/tracing/buffer_size_kb


          And check it:



          root@s15:/home/doug/temp-k-git/linux# free -m
          total used free shared buff/cache available
          Mem: 15719 88 15470 1 160 15342
          Swap: 16085 35 16050


          If you want the time to be 180 seconds, then bundle up the above into a script with a 180 second sleep time. However, you will still have to check the available number as your starting point.






          share|improve this answer



























            Your Answer








            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "89"
            ;
            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',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            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/4.0/"u003ecc by-sa 4.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%2faskubuntu.com%2fquestions%2f1171147%2fhow-to-reduce-free-memory-to-certain-number-for-specific-time-duration%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown


























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0



















            One could use the kernel trace buffer as a way to reduce available memory left for the system and/or user. Example, using my system with 16 gigabytes and 8 CPUs:



            First flush memory, giving our starting point (note that I am running as root):



            root@s15:/home/doug/temp-k-git/linux# sync
            root@s15:/home/doug/temp-k-git/linux# echo 3 > /proc/sys/vm/drop_caches
            root@s15:/home/doug/temp-k-git/linux# free -m
            total used free shared buff/cache available
            Mem: 15719 88 15472 1 159 15343
            Swap: 16085 35 16050


            Now, calculate and allocate the memory to the kernel trace buffer: 5% of 15719 megabytyes is 786 megabytes. Starting from 15472 megabytyes, Then 14686 megabyytes need to be used. The kernel trace buffer is per CPU, in my case 8 CPUs, so 1835 megabytes per CPU. Allocate:



            root@s15:/home/doug/temp-k-git/linux# echo 1835000 > /sys/kernel/debug/tracing/buffer_size_kb


            And check it:



            root@s15:/home/doug/temp-k-git/linux# free -m
            total used free shared buff/cache available
            Mem: 15719 14476 858 1 385 730
            Swap: 16085 35 16050


            You can observe that it resulted in 5.46% of memory still available (tweek the allocation, if needed). Once you have done whatever testing, then you can de-allocate the kernel trace buffer with (0 does not work):



            root@s15:/home/doug/temp-k-git/linux# echo 1 > /sys/kernel/debug/tracing/buffer_size_kb


            And check it:



            root@s15:/home/doug/temp-k-git/linux# free -m
            total used free shared buff/cache available
            Mem: 15719 88 15470 1 160 15342
            Swap: 16085 35 16050


            If you want the time to be 180 seconds, then bundle up the above into a script with a 180 second sleep time. However, you will still have to check the available number as your starting point.






            share|improve this answer






























              0



















              One could use the kernel trace buffer as a way to reduce available memory left for the system and/or user. Example, using my system with 16 gigabytes and 8 CPUs:



              First flush memory, giving our starting point (note that I am running as root):



              root@s15:/home/doug/temp-k-git/linux# sync
              root@s15:/home/doug/temp-k-git/linux# echo 3 > /proc/sys/vm/drop_caches
              root@s15:/home/doug/temp-k-git/linux# free -m
              total used free shared buff/cache available
              Mem: 15719 88 15472 1 159 15343
              Swap: 16085 35 16050


              Now, calculate and allocate the memory to the kernel trace buffer: 5% of 15719 megabytyes is 786 megabytes. Starting from 15472 megabytyes, Then 14686 megabyytes need to be used. The kernel trace buffer is per CPU, in my case 8 CPUs, so 1835 megabytes per CPU. Allocate:



              root@s15:/home/doug/temp-k-git/linux# echo 1835000 > /sys/kernel/debug/tracing/buffer_size_kb


              And check it:



              root@s15:/home/doug/temp-k-git/linux# free -m
              total used free shared buff/cache available
              Mem: 15719 14476 858 1 385 730
              Swap: 16085 35 16050


              You can observe that it resulted in 5.46% of memory still available (tweek the allocation, if needed). Once you have done whatever testing, then you can de-allocate the kernel trace buffer with (0 does not work):



              root@s15:/home/doug/temp-k-git/linux# echo 1 > /sys/kernel/debug/tracing/buffer_size_kb


              And check it:



              root@s15:/home/doug/temp-k-git/linux# free -m
              total used free shared buff/cache available
              Mem: 15719 88 15470 1 160 15342
              Swap: 16085 35 16050


              If you want the time to be 180 seconds, then bundle up the above into a script with a 180 second sleep time. However, you will still have to check the available number as your starting point.






              share|improve this answer




























                0















                0











                0









                One could use the kernel trace buffer as a way to reduce available memory left for the system and/or user. Example, using my system with 16 gigabytes and 8 CPUs:



                First flush memory, giving our starting point (note that I am running as root):



                root@s15:/home/doug/temp-k-git/linux# sync
                root@s15:/home/doug/temp-k-git/linux# echo 3 > /proc/sys/vm/drop_caches
                root@s15:/home/doug/temp-k-git/linux# free -m
                total used free shared buff/cache available
                Mem: 15719 88 15472 1 159 15343
                Swap: 16085 35 16050


                Now, calculate and allocate the memory to the kernel trace buffer: 5% of 15719 megabytyes is 786 megabytes. Starting from 15472 megabytyes, Then 14686 megabyytes need to be used. The kernel trace buffer is per CPU, in my case 8 CPUs, so 1835 megabytes per CPU. Allocate:



                root@s15:/home/doug/temp-k-git/linux# echo 1835000 > /sys/kernel/debug/tracing/buffer_size_kb


                And check it:



                root@s15:/home/doug/temp-k-git/linux# free -m
                total used free shared buff/cache available
                Mem: 15719 14476 858 1 385 730
                Swap: 16085 35 16050


                You can observe that it resulted in 5.46% of memory still available (tweek the allocation, if needed). Once you have done whatever testing, then you can de-allocate the kernel trace buffer with (0 does not work):



                root@s15:/home/doug/temp-k-git/linux# echo 1 > /sys/kernel/debug/tracing/buffer_size_kb


                And check it:



                root@s15:/home/doug/temp-k-git/linux# free -m
                total used free shared buff/cache available
                Mem: 15719 88 15470 1 160 15342
                Swap: 16085 35 16050


                If you want the time to be 180 seconds, then bundle up the above into a script with a 180 second sleep time. However, you will still have to check the available number as your starting point.






                share|improve this answer














                One could use the kernel trace buffer as a way to reduce available memory left for the system and/or user. Example, using my system with 16 gigabytes and 8 CPUs:



                First flush memory, giving our starting point (note that I am running as root):



                root@s15:/home/doug/temp-k-git/linux# sync
                root@s15:/home/doug/temp-k-git/linux# echo 3 > /proc/sys/vm/drop_caches
                root@s15:/home/doug/temp-k-git/linux# free -m
                total used free shared buff/cache available
                Mem: 15719 88 15472 1 159 15343
                Swap: 16085 35 16050


                Now, calculate and allocate the memory to the kernel trace buffer: 5% of 15719 megabytyes is 786 megabytes. Starting from 15472 megabytyes, Then 14686 megabyytes need to be used. The kernel trace buffer is per CPU, in my case 8 CPUs, so 1835 megabytes per CPU. Allocate:



                root@s15:/home/doug/temp-k-git/linux# echo 1835000 > /sys/kernel/debug/tracing/buffer_size_kb


                And check it:



                root@s15:/home/doug/temp-k-git/linux# free -m
                total used free shared buff/cache available
                Mem: 15719 14476 858 1 385 730
                Swap: 16085 35 16050


                You can observe that it resulted in 5.46% of memory still available (tweek the allocation, if needed). Once you have done whatever testing, then you can de-allocate the kernel trace buffer with (0 does not work):



                root@s15:/home/doug/temp-k-git/linux# echo 1 > /sys/kernel/debug/tracing/buffer_size_kb


                And check it:



                root@s15:/home/doug/temp-k-git/linux# free -m
                total used free shared buff/cache available
                Mem: 15719 88 15470 1 160 15342
                Swap: 16085 35 16050


                If you want the time to be 180 seconds, then bundle up the above into a script with a 180 second sleep time. However, you will still have to check the available number as your starting point.







                share|improve this answer













                share|improve this answer




                share|improve this answer










                answered Sep 6 at 15:20









                Doug SmythiesDoug Smythies

                8,4383 gold badges20 silver badges32 bronze badges




                8,4383 gold badges20 silver badges32 bronze badges































                    draft saved

                    draft discarded















































                    Thanks for contributing an answer to Ask Ubuntu!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1171147%2fhow-to-reduce-free-memory-to-certain-number-for-specific-time-duration%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown









                    Popular posts from this blog

                    Tamil (spriik) Luke uk diar | Nawigatjuun

                    Align equal signs while including text over equalitiesAMS align: left aligned text/math plus multicolumn alignmentMultiple alignmentsAligning equations in multiple placesNumbering and aligning an equation with multiple columnsHow to align one equation with another multline equationUsing \ in environments inside the begintabularxNumber equations and preserving alignment of equal signsHow can I align equations to the left and to the right?Double equation alignment problem within align enviromentAligned within align: Why are they right-aligned?

                    Where does the image of a data connector as a sharp metal spike originate from?Where does the concept of infected people turning into zombies only after death originate from?Where does the motif of a reanimated human head originate?Where did the notion that Dragons could speak originate?Where does the archetypal image of the 'Grey' alien come from?Where did the suffix '-Man' originate?Where does the notion of being injured or killed by an illusion originate?Where did the term “sophont” originate?Where does the trope of magic spells being driven by advanced technology originate from?Where did the term “the living impaired” originate?