1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

PHP CLI Question and Memory Usage

Discussion in 'General PHP and MySQL Discussions' started by robdog, Jun 14, 2013.

  1. robdog

    robdog Well-Known Member

    I have PHP script that I run through CLI and it is using A LOT of memory. (but it is doing a ton of work)

    What techniques should I use to free up memory during the CLI processing?
     
  2. Shamil

    Shamil Well-Known Member

    What does your script do?
     
  3. robdog

    robdog Well-Known Member

    A ton of DB queries inside a foreach loop. I have tried using UNSET and the built in PHP garbage collection tags, but nothing really seems to be helping.
     
  4. Shamil

    Shamil Well-Known Member

    I'm generally scared of things like this:

    PHP:
    foreach ($array as $key => $data){
         
    $query "UPDATE ...";
         
    $db->query($query);
    }

    Have you profiled your script?
     
  5. digitalpoint

    digitalpoint Well-Known Member

    Do you have XenForo's debug config option enabled? It stores a lot of info for each query run...
     
    xf_phantom likes this.

Share This Page