PHP Fatal error: Out of memory (Apache crash)

Discussion in 'PHP' started by solinem, Sep 27, 2008.

  1. #1
    Hi:
    I am somehow newbie and am trapped into a problem.
    I am trying to find a solution for this error that consequentially leads to Apache Server crash.
    Following is the message as seen in the error.log file:
    PHP Fatal error: Out of memory (allocated 786432) (tried to allocate 32768 bytes)

    SERVER CHARACTERISTICS:
    • Windows 2008 Enterprise Server
    • PHP 5.2.6
    • Apache/2.2.4 (Win32) DAV/2 mod_ssl/2.2.4 OpenSSL/0.9.8e
    • RAM=8gb,
    PHP SERVER PARAMETERS:
    • max_execution_time = 720
    • max_input_time = 360
    • memory_limit = 5120 MB
    After a few messages like this, the server ends with the message:
    [notice] Parent: child process exited with status 255 -- Restarting.

    Whenever it happens, I don't see a substantial rise in memory usage (well under the 5GB established in the configuration)
    I think part of the problem is originated because the server is not releasing memory, and the data is adding-up.
    It is surely a misconfiguration of my server
    I have searched everywhere but didn't found a satisfying solution.

    Thanks for your help.
     

    Attached Files:

    solinem, Sep 27, 2008 IP
  2. juust

    juust Peon

    Messages:
    214
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Go to the Apache forum.
    They know.
    Some on the php forum might know, I for one don't.
     
    juust, Sep 27, 2008 IP
  3. piehead2000

    piehead2000 Peon

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Try changing php.ini to...

    memory_limit = 128M

    and add to httpd.conf
    RLimitMEM 1073741824 2147483648

    restart & pray
     
    piehead2000, Sep 27, 2008 IP
  4. imphpguru

    imphpguru Active Member

    Messages:
    439
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    55
    #4
    Hi,
    These things may happen also because of imperfect script. Be sure to check your script for memory leaks! More often than not is our logical error than the system error. All the best.

    Thanks

    imphp
     
    imphpguru, Sep 27, 2008 IP
  5. Barti1987

    Barti1987 Well-Known Member

    Messages:
    2,703
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    185
    #5
    Increase the memory limit variable in php.ini

    Peace,
     
    Barti1987, Sep 27, 2008 IP
  6. NatalicWolf

    NatalicWolf Peon

    Messages:
    262
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Check for any loops...You most likely are hitting a snag point where the script violently loops into a death spin. I can help if you need, hit me up my PM or IM.
     
    NatalicWolf, Sep 27, 2008 IP
  7. joebert

    joebert Well-Known Member

    Messages:
    2,150
    Likes Received:
    88
    Best Answers:
    0
    Trophy Points:
    145
    #7
    The first thing I'd try is setting a non-infinate limit for that in httpd.conf
    I believe forcing the worker threads to respawn occasionally will free up memory.
     
    joebert, Sep 27, 2008 IP
  8. solinem

    solinem Peon

    Messages:
    16
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    I've made changes to this parameter, trying values from 5, 10, to 500 and always ends with the same result:
    after the specified number of threads, the server "crashes" or stops working (I really don't know if apache "shuts down" normally or not", there isn't any evidence).
     
    solinem, Sep 29, 2008 IP
  9. solinem

    solinem Peon

    Messages:
    16
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    thanks,
    I started with 64MB, passed to 128, 256, 1024, 2048, now the value is in 5120 MB and the problem persists (the server doesn't indicate memory usage over 2GB).
    I think the problem isn't really in the memory assigned in PHP, but is limited by Apache, somewhere else.
    There is also the fact that apparently the memory isn't released at a sufficient "rate", so it "builds-up"
     
    solinem, Sep 29, 2008 IP
  10. solinem

    solinem Peon

    Messages:
    16
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Thanks, after modifying my httpd.conf file, an error is generated in the error.log file (My server is Windows 2008):
    [error] RLimitMEM not supported on this platform
     
    solinem, Sep 29, 2008 IP
  11. solinem

    solinem Peon

    Messages:
    16
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Thanks,
    how can I check for them, is there any technique to detect them?
    I have checked code and it seems there is no problem.
     
    solinem, Sep 29, 2008 IP
  12. solinem

    solinem Peon

    Messages:
    16
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #12
    Thanks,
    I have done, but the server emits an error:
    [error] RLimitMEM not supported on this platform
    My OS = Win2008 Server
     
    solinem, Sep 29, 2008 IP
  13. javaongsan

    javaongsan Well-Known Member

    Messages:
    1,054
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    128
    #13
    There's your problem

    try it out on a linux server.
     
    javaongsan, Sep 29, 2008 IP
  14. nirajkum

    nirajkum Active Member

    Messages:
    815
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    58
    #14
    memory limit variable in php.ini file is one option can you please check that on your linux server ... core dump is not getting created because your program crash ... this happens lot of time and you never come 2 know
     
    nirajkum, Sep 29, 2008 IP
  15. solinem

    solinem Peon

    Messages:
    16
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #15
    Thanks,
    unfortunately, my server is Windows 2008, I have a correction on the configuration
    from: memory_limit = 5120 MB to: memory_limit = 5120M
    maybe it can help, but I'm still anxious about the memory "build-up".
     
    solinem, Oct 2, 2008 IP
  16. solinem

    solinem Peon

    Messages:
    16
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #16
    Thanks,
    I suggested a RHEL, but the decision was to purchase Win2008 enterprise (a lot more money)
     
    solinem, Oct 2, 2008 IP
  17. javaongsan

    javaongsan Well-Known Member

    Messages:
    1,054
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    128
    #17
    you can try this solution, It works for me on windows using XAMPPLITE.
    Add
    ini_set('memory_limit', -1);
    Code (markup):
    to your code.
     
    javaongsan, Oct 2, 2008 IP