how do I reduce the memory usage of php?

Discussion in 'PHP' started by incognito1, Feb 11, 2011.

  1. #1
    I'm using nginx with php-fpm. Right now my php processes use about 15-20mb of memory before they're killed and restarted. What I'm trying to do is get this down to <10mb. Is this possible?
     
    incognito1, Feb 11, 2011 IP
  2. G3n3s!s

    G3n3s!s Active Member

    Messages:
    325
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    80
    #2
    yes. Unset all not necessary variables & try not to do loops in your codes(

    while (1)
    {
    //this is wrong
    }

    try it another way. That's all I can recomend for you.
     
    G3n3s!s, Feb 11, 2011 IP
  3. krdzal

    krdzal Peon

    Messages:
    105
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Do not create huge arrays. They consume a lot of memory
     
    krdzal, Feb 11, 2011 IP
  4. mastermunj

    mastermunj Well-Known Member

    Messages:
    687
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    110
    #4
    If you can share more details about what exactly your php processes try to do for consuming even 10MB of memory, we will be able to help you better.

    You can share key steps involved in process so that we can ask more details about the fishy one amongst those.
     
    mastermunj, Feb 12, 2011 IP
  5. jazzcho

    jazzcho Peon

    Messages:
    326
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Use APC cache.
     
    jazzcho, Feb 13, 2011 IP
  6. srisen2

    srisen2 Peon

    Messages:
    359
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #6
    you can try running php with different handlers as running php in dso generally uses less memory than running it in suphp although you have to deal with more file security with dso
     
    srisen2, Feb 14, 2011 IP