Running out of memory, fork can't allocate memory











up vote
1
down vote

favorite












We are getting out of memory frequently, as well fork cannot allocate memory. I did some investigation.



It seems that scripts are not case as I thought before this. I will share information which I get after analyzing.



I have isolated server, so other people cant reach to server. This will show "true" memory usage in this case.




  1. I have no mysqld and apache started [memory usage ~182mb].

  2. just started mysqld. no connections made to mysqld [mu ~340mb].

  3. httpd started [~360mb].

  4. first request to script. [~630mb]. But!! The most interesting part. Memory doesn't get deallocated. Everything looks OK. Script ended, page loaded successfuly. But it still around ~630mb.


Why one request eats 270MB? Why thats not deallocated after request?



Some stats:




  • Server RAM 512 MB guaranteed

  • 256 MB burstable

  • PHP memory limit: 256MB


httpd.conf



<IfModule prefork.c>
StartServers 1
MinSpareServers 1
MaxSpareServers 3
ServerLimit 50
MaxClients 50
MaxRequestsPerChild 50
</IfModule>









share|improve this question




















  • 1




    What else is started? ~180MiB RAM after boot into headless system sounds unreasonable. Also, what does that script do? How big is the database backing it up?
    – Bobby
    Mar 21 '12 at 13:14










  • What is exactly "memory usage"? How did you measure it? Is it the one from the first line of free?
    – Cristian Ciupitu
    Mar 21 '12 at 13:58










  • Bobby, this is "ps faux" pastebin.com/4yKGBTyj
    – Toktik
    Mar 21 '12 at 15:39












  • Cristian, yes, it is from "free" command, also from mediatemple server status, which is the same. Also "cat /proc/user_beancounters" pastebin.com/H9FZkFWj
    – Toktik
    Mar 21 '12 at 15:39










  • Looks to me like a bulk of it is going to httpd.
    – JeffG
    Mar 22 '12 at 1:41















up vote
1
down vote

favorite












We are getting out of memory frequently, as well fork cannot allocate memory. I did some investigation.



It seems that scripts are not case as I thought before this. I will share information which I get after analyzing.



I have isolated server, so other people cant reach to server. This will show "true" memory usage in this case.




  1. I have no mysqld and apache started [memory usage ~182mb].

  2. just started mysqld. no connections made to mysqld [mu ~340mb].

  3. httpd started [~360mb].

  4. first request to script. [~630mb]. But!! The most interesting part. Memory doesn't get deallocated. Everything looks OK. Script ended, page loaded successfuly. But it still around ~630mb.


Why one request eats 270MB? Why thats not deallocated after request?



Some stats:




  • Server RAM 512 MB guaranteed

  • 256 MB burstable

  • PHP memory limit: 256MB


httpd.conf



<IfModule prefork.c>
StartServers 1
MinSpareServers 1
MaxSpareServers 3
ServerLimit 50
MaxClients 50
MaxRequestsPerChild 50
</IfModule>









share|improve this question




















  • 1




    What else is started? ~180MiB RAM after boot into headless system sounds unreasonable. Also, what does that script do? How big is the database backing it up?
    – Bobby
    Mar 21 '12 at 13:14










  • What is exactly "memory usage"? How did you measure it? Is it the one from the first line of free?
    – Cristian Ciupitu
    Mar 21 '12 at 13:58










  • Bobby, this is "ps faux" pastebin.com/4yKGBTyj
    – Toktik
    Mar 21 '12 at 15:39












  • Cristian, yes, it is from "free" command, also from mediatemple server status, which is the same. Also "cat /proc/user_beancounters" pastebin.com/H9FZkFWj
    – Toktik
    Mar 21 '12 at 15:39










  • Looks to me like a bulk of it is going to httpd.
    – JeffG
    Mar 22 '12 at 1:41













up vote
1
down vote

favorite









up vote
1
down vote

favorite











We are getting out of memory frequently, as well fork cannot allocate memory. I did some investigation.



It seems that scripts are not case as I thought before this. I will share information which I get after analyzing.



I have isolated server, so other people cant reach to server. This will show "true" memory usage in this case.




  1. I have no mysqld and apache started [memory usage ~182mb].

  2. just started mysqld. no connections made to mysqld [mu ~340mb].

  3. httpd started [~360mb].

  4. first request to script. [~630mb]. But!! The most interesting part. Memory doesn't get deallocated. Everything looks OK. Script ended, page loaded successfuly. But it still around ~630mb.


Why one request eats 270MB? Why thats not deallocated after request?



Some stats:




  • Server RAM 512 MB guaranteed

  • 256 MB burstable

  • PHP memory limit: 256MB


httpd.conf



<IfModule prefork.c>
StartServers 1
MinSpareServers 1
MaxSpareServers 3
ServerLimit 50
MaxClients 50
MaxRequestsPerChild 50
</IfModule>









share|improve this question















We are getting out of memory frequently, as well fork cannot allocate memory. I did some investigation.



It seems that scripts are not case as I thought before this. I will share information which I get after analyzing.



I have isolated server, so other people cant reach to server. This will show "true" memory usage in this case.




  1. I have no mysqld and apache started [memory usage ~182mb].

  2. just started mysqld. no connections made to mysqld [mu ~340mb].

  3. httpd started [~360mb].

  4. first request to script. [~630mb]. But!! The most interesting part. Memory doesn't get deallocated. Everything looks OK. Script ended, page loaded successfuly. But it still around ~630mb.


Why one request eats 270MB? Why thats not deallocated after request?



Some stats:




  • Server RAM 512 MB guaranteed

  • 256 MB burstable

  • PHP memory limit: 256MB


httpd.conf



<IfModule prefork.c>
StartServers 1
MinSpareServers 1
MaxSpareServers 3
ServerLimit 50
MaxClients 50
MaxRequestsPerChild 50
</IfModule>






linux memory apache-http-server php






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 21 '12 at 13:36









slhck

158k46434461




158k46434461










asked Mar 21 '12 at 12:26









Toktik

10914




10914








  • 1




    What else is started? ~180MiB RAM after boot into headless system sounds unreasonable. Also, what does that script do? How big is the database backing it up?
    – Bobby
    Mar 21 '12 at 13:14










  • What is exactly "memory usage"? How did you measure it? Is it the one from the first line of free?
    – Cristian Ciupitu
    Mar 21 '12 at 13:58










  • Bobby, this is "ps faux" pastebin.com/4yKGBTyj
    – Toktik
    Mar 21 '12 at 15:39












  • Cristian, yes, it is from "free" command, also from mediatemple server status, which is the same. Also "cat /proc/user_beancounters" pastebin.com/H9FZkFWj
    – Toktik
    Mar 21 '12 at 15:39










  • Looks to me like a bulk of it is going to httpd.
    – JeffG
    Mar 22 '12 at 1:41














  • 1




    What else is started? ~180MiB RAM after boot into headless system sounds unreasonable. Also, what does that script do? How big is the database backing it up?
    – Bobby
    Mar 21 '12 at 13:14










  • What is exactly "memory usage"? How did you measure it? Is it the one from the first line of free?
    – Cristian Ciupitu
    Mar 21 '12 at 13:58










  • Bobby, this is "ps faux" pastebin.com/4yKGBTyj
    – Toktik
    Mar 21 '12 at 15:39












  • Cristian, yes, it is from "free" command, also from mediatemple server status, which is the same. Also "cat /proc/user_beancounters" pastebin.com/H9FZkFWj
    – Toktik
    Mar 21 '12 at 15:39










  • Looks to me like a bulk of it is going to httpd.
    – JeffG
    Mar 22 '12 at 1:41








1




1




What else is started? ~180MiB RAM after boot into headless system sounds unreasonable. Also, what does that script do? How big is the database backing it up?
– Bobby
Mar 21 '12 at 13:14




What else is started? ~180MiB RAM after boot into headless system sounds unreasonable. Also, what does that script do? How big is the database backing it up?
– Bobby
Mar 21 '12 at 13:14












What is exactly "memory usage"? How did you measure it? Is it the one from the first line of free?
– Cristian Ciupitu
Mar 21 '12 at 13:58




What is exactly "memory usage"? How did you measure it? Is it the one from the first line of free?
– Cristian Ciupitu
Mar 21 '12 at 13:58












Bobby, this is "ps faux" pastebin.com/4yKGBTyj
– Toktik
Mar 21 '12 at 15:39






Bobby, this is "ps faux" pastebin.com/4yKGBTyj
– Toktik
Mar 21 '12 at 15:39














Cristian, yes, it is from "free" command, also from mediatemple server status, which is the same. Also "cat /proc/user_beancounters" pastebin.com/H9FZkFWj
– Toktik
Mar 21 '12 at 15:39




Cristian, yes, it is from "free" command, also from mediatemple server status, which is the same. Also "cat /proc/user_beancounters" pastebin.com/H9FZkFWj
– Toktik
Mar 21 '12 at 15:39












Looks to me like a bulk of it is going to httpd.
– JeffG
Mar 22 '12 at 1:41




Looks to me like a bulk of it is going to httpd.
– JeffG
Mar 22 '12 at 1:41










1 Answer
1






active

oldest

votes

















up vote
0
down vote














Why one request eats 270MB?




Likely because it accessed a lot of data or metadata in or about files on disk.




Why thats not deallocated after request?




Because the data might be used again soon. Deallocating it after the request makes the next request expensive. It makes more sense to defer the deallocation until the memory is actually needed for something else.






share|improve this answer





















    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "3"
    };
    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: 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/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%2fsuperuser.com%2fquestions%2f403211%2frunning-out-of-memory-fork-cant-allocate-memory%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








    up vote
    0
    down vote














    Why one request eats 270MB?




    Likely because it accessed a lot of data or metadata in or about files on disk.




    Why thats not deallocated after request?




    Because the data might be used again soon. Deallocating it after the request makes the next request expensive. It makes more sense to defer the deallocation until the memory is actually needed for something else.






    share|improve this answer

























      up vote
      0
      down vote














      Why one request eats 270MB?




      Likely because it accessed a lot of data or metadata in or about files on disk.




      Why thats not deallocated after request?




      Because the data might be used again soon. Deallocating it after the request makes the next request expensive. It makes more sense to defer the deallocation until the memory is actually needed for something else.






      share|improve this answer























        up vote
        0
        down vote










        up vote
        0
        down vote










        Why one request eats 270MB?




        Likely because it accessed a lot of data or metadata in or about files on disk.




        Why thats not deallocated after request?




        Because the data might be used again soon. Deallocating it after the request makes the next request expensive. It makes more sense to defer the deallocation until the memory is actually needed for something else.






        share|improve this answer













        Why one request eats 270MB?




        Likely because it accessed a lot of data or metadata in or about files on disk.




        Why thats not deallocated after request?




        Because the data might be used again soon. Deallocating it after the request makes the next request expensive. It makes more sense to defer the deallocation until the memory is actually needed for something else.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Oct 17 '17 at 6:31









        David Schwartz

        56.1k684128




        56.1k684128






























             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f403211%2frunning-out-of-memory-fork-cant-allocate-memory%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

            flock() on closed filehandle LOCK_FILE at /usr/bin/apt-mirror

            Mangá

             ⁒  ․,‪⁊‑⁙ ⁖, ⁇‒※‌, †,⁖‗‌⁝    ‾‸⁘,‖⁔⁣,⁂‾
”‑,‥–,‬ ,⁀‹⁋‴⁑ ‒ ,‴⁋”‼ ⁨,‷⁔„ ‰′,‐‚ ‥‡‎“‷⁃⁨⁅⁣,⁔
⁇‘⁔⁡⁏⁌⁡‿‶‏⁨ ⁣⁕⁖⁨⁩⁥‽⁀  ‴‬⁜‟ ⁃‣‧⁕‮ …‍⁨‴ ⁩,⁚⁖‫ ,‵ ⁀,‮⁝‣‣ ⁑  ⁂– ․, ‾‽ ‏⁁“⁗‸ ‾… ‹‡⁌⁎‸‘ ‡⁏⁌‪ ‵⁛ ‎⁨ ―⁦⁤⁄⁕