title: Allowed memory size of 8589934592 bytes exhausted
body: <p>I encountering issue on my schedule on Laravel.</p>
  
  <p>I see that there is duplicate questions about this error but these don't fix my issue</p>
  
  <blockquote>
    <p>root@trafficshield:/var/www/vhosts/trafficshield.tools/httpdocs#
    /opt/plesk/php/7.1/bin/php artisan schedule:run  Running scheduled
    command: Closure ^[[15~PHP Fatal error:  Allowed memory size of
    8589934592 bytes exhausted (tried to allocate 4096 bytes) in
    /var/www/vhosts/trafficshield.tools/httpdocs/vendor/laravel/framework/src/Illum
    inate/Database/Eloquent/Model.php on line 279 PHP</p>
  </blockquote>
  
  <p>This schedule aim to count all the visits of all campains on our service. </p>
  
  <pre><code>    $schedule-&gt;call(function () {
          $campaigns = Campaign::all();
          foreach ($campaigns as $campaign) {
              $campaign-&gt;denied_visits = $campaign-&gt;visitsDenied-&gt;count();
              $campaign-&gt;allowed_visits = $campaign-&gt;visitsAllowed-&gt;count();
              $campaign-&gt;save();
          }
      })-&gt;everyFiveMinutes();
  </code></pre>
  
  <p>How can I change the PHP code the avoid this issue ?</p>
  
  <p>Config : <code>memory_limit : 8G</code></p>
  
  <p>Thank's in advance for your help.</p>