Fatal Error - Allowed Memory - PHP

Asked

Viewed 332 times

1

I have the following problem, when having run my script via browser it works smoothly and very fast, but when trying on CMD it consumes all memory and error.

Via browser: http://170.30.255.100:88/call_email_gerente_conta.php

Via cdm:

"C:\Program Files (x86)\iis\PHP\v5.6\php.exe" E:\site\call_email_gerente_conta.php

Erro: Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate
 36 bytes) in E:\site\call_email_gerente_conta.php on line 8

Any idea why this behavior, my csv has only 3 lines.

<?php
  $file = fopen('Lista_responsaveis.csv', 'r');
  $i=0;

  while (($line = fgetcsv($file)) !== FALSE)
  {
     $responsavel[$i]=$line[0];
     $i++;
 }
 fclose($file);

 unset($responsavel[0]);

 foreach ($responsavel as $item)
 {
    echo '</br>';
    include("email_gerente_conta.php");
 }

 ?>
  • What version is being used on the web

  • The web version is the same as the CLI version

1 answer

-1

Run by CLI(Command line interface) really requires more memory than by the browser and passes the allocated pattern, so you should run the code with a -d or -define and change the memory limit -> memory_limit

php -d memory_limit=128M E:\site\call_email_gerente_conta.php

With the -d parameter you can change any php.ini configuration

Source and examples

  • Hello, still the same mistake

  • Did you try to allocate a larger amount of memory? 512MB for example

  • Yeah, same thing.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.