0

This is my code:

    <?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");
 }

 ?>

And it works very well in my browser : http://174.30.255.100:88/call_email_gerente_conta.php

but if i do this in my cdm:

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

I get this error message: 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

I already tried increase memory to 128m, 512 and 1g, but still crashing, i'll avoid to use "-d memory_limit=-1", this error message refers to my loop, but i dont understant why this works fine on my browser and not in my cmd, and why a code quite simple and with a csv that has only 3 lines, need this much of memory Any help please

2
  • So, basically your question boils down to why it consumes different amounts of memory in different environments, right? I could guess, but first, you need to provide an MCVE! Reason is that without it, your question is off topic and secondly that guessing is bad. Commented Feb 19, 2018 at 20:26
  • Hi Ulrich, i just want that my code work on my cmd like works on my browser ( if you could answer the reason about this diference will be a plus for me). Could you tell me whats is a MCVE? and if you can´t help, like Denis, please dont wast your and my time. Thank you Commented Feb 19, 2018 at 20:44

1 Answer 1

0

You need to change php.ini.

And change number of allowed space.

Link is here

If you have access to specify server (Ubuntu or Windows) You need to change specify file in Apache/conf or php/conf

It can be here or here

Sign up to request clarification or add additional context in comments.

6 Comments

Hi Denis, when i use the paramether -d memory_limit=512M or 1024M the falta error message change with it, From Fatal error: Allowed memory size of 134217728 To Fatal error: Allowed memory size of 1073741824 bytes, but just in case i changed in my php.ini with the same result, and i don't use apache, i use iis.
I recommend you try to allow something like 5000M or more, and see what happened. But you can see same error, i think here. And I recommend for php use Apache, it doesn't matter on witch os, Ubuntu or Windows, but for me priority is Ubuntu, it personal recommendation.
I already tried with 1GB, and i can't use Apache because that server is from my work.
5000M = 1G, rigtht? Just try to use 5G, if it possible. And let me look the answer, i mean error, if it back it.
Hi Denis, i tried a new approach, i change my code for this (sorry put my code here): $row = 1; if (($handle = fopen("Lista_responsaveis.csv", "r")) !== FALSE) { while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { $num = count($data); echo "Test 1"; $row++; } fclose($handle); } else { echo "Test 2"; } and now my browser show me Test1 and my cmd Test2 !
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.