title: PHP CLI "Out of memory" error on VPS server running CentOS with cPanel
body: <p>I'm running Symfony2.1 on a hosted virtual server running CentOS with cPanel. Everything runs fine except that I can no longer use Symfony CLI commands. I'm getting this:</p>
  
  <pre><code>Fatal error: Out of memory (allocated 20185088) (tried to allocate 71 bytes)
  </code></pre>
  
  <p>error (for example when I try to run <code>php app/console cache:clear --env=prod</code> or other useful Symfony commands).</p>
  
  <p>I've used the same commands through the CLI for months without any problem until a few days ago when this error came out. I haven't been able to overcome this error since then.</p>
  
  <p>I want to point out that this not a PHP memory_limit related error (see below), being an "Out of memory" error and not an "Allocated memory size" error.</p>
  
  <p>The exact same commands run perfectly when added to a cron job (this is the temporary workaround I'm using now), meaning that the scripts themselves are not to be blamed.</p>
  
  <h1>What I've tried to do so far:</h1>
  
  <ul>
  <li><p><strong>Increase memory_limit in php.ini</strong> (or directly on the command line) : as I suspected from the type of error I'm having, this had no effect</p></li>
  <li><p><strong>Search for any other php.ini file</strong> that may overwrite this setting for the CLI : there was none</p></li>
  <li><p><strong>Monitoring memory usage</strong> with free -m : there was plenty of memory available (which was expected, as the symfony commands run perfectly through cron jobs)</p></li>
  <li><p>Trying to find <strong>if WHM/cPanel might have</strong>, through an update for example, <strong>set any memory restriction</strong> for user accounts : I've found that this might be the case when using a jailed SSH shell (but thing is, I'm not, I'm using normal SSH shell), or if enabling Shell Fork Bomb protection (but no, this is disabled on my server)</p></li>
  <li><p><strong>Checking ulimit settings</strong> on my server/account with ulimit -a : there are limits, but they amount to 256M whereas my "Out of memory" error indicated that no more than 20M seem to be allowed to PHP CLI</p></li>
  <li><p>Checking if there was any memory restriction somewhere in .conf files, especially in <strong>/etc/security/limits.conf</strong>: there was none</p></li>
  <li><p><strong>Checking for any other file that could set up that kind of memory restriction: this time I indeed found one, namely /usr/local/cpanel/etc/login_profile/limits.sh</strong> which seem to set such limit (ulimit -n 100 -u 35 -m 20000 -d 20000 -s 8192 -c 20000 -v unlimited 2>/dev/null) => I thought I'd finally found the culprit, as the numbers (20000) seem to correspond, <strong>but editing this file as root and logging again in my account through SSH had, again, no effect</strong></p></li>
  </ul>
  
  <h1>My question :</h1>
  
  <p>I've now run out of options. I contacted my host but they are as clueless as I am (a lot more really, they don't even know about Symfony). Is there anyone out there who experienced the same problem?</p>
  
  <p>If, by any chance, the <code>/usr/local/cpanel/etc/login_profile/limits.sh</code> have gotten me close to the answer, what I am missing? Do I need to reboot the server or restart cPanel, instead of just re-logging to my account?</p>
  
  <p>On a side note, is this something that might-be related to a WHM/cPanel update (as stated, everything was working perfectly on the command line until a few days ago)?</p>
  
  <p>Thanks for any help, and sorry for the long question.</p>
  
  <p>PS: I've found other similar questions on Stack Overflow, but each of them was solved using one of the things I've already tried. So I guess I'm experiencing a different problem.</p>