S
S
Sarvar Abduhakimov2015-05-14 16:06:37
PHP
Sarvar Abduhakimov, 2015-05-14 16:06:37

How to fix the out of memory allocated 1404829696 error?

when writing data to excel using php, it gives an error out of memory (allocated 1404829696). I tried to add ini_set (), changed php.ini but everything exactly gives such an error

Answer the question

In order to leave comments, you need to log in

5 answer(s)
S
Shaks, 2015-05-14
@shaks

memory is clogged, you need to clean up the value of variables. but because to litter so much memory, you still have to manage, which means most likely you have an eternal cycle there somewhere or some kind of array grows exponentially.

S
Sergey, 2015-05-14
@Pjeroo

How much data are you trying to write? PhpExcel is a very gluttonous thing, it might be worth writing in parts, you also need to check the code for what shaks said

D
des1roer, 2015-05-14
@des1roer

regular topic. only I had such a joke with ms sql. I remember explicitly specifying column types. and you feel free to write how you overcame the problem

S
Sarvar Abduhakimov, 2015-05-14
@Sarvar4ik

$i = 0;
  $file_name = 'xls/Spisok.xls';
  $file_name1 = 'xls/Spisok1.xls';
  require_once 'classes/PHPExcel.php'; 
  $phpexcel = PHPExcel_IOFactory::load($file_name);
  $page = $phpexcel->setActiveSheetIndex(0); 
$query = 'SELECT * FROM list';	
$result = pg_query($query) or die('Zaprosda muammo: ' . pg_last_error());	
while ($line = pg_fetch_array($result, null, PGSQL_ASSOC)) {	
  $j = $i+2;

  $page->setCellValueByColumnAndRow(0,$j,$line4["p_id"]);
  
  $page->setCellValueByColumnAndRow(1,$j,$line4["surname"]);
  
  $page->setCellValueByColumnAndRow(2,$j,$line4["name"]);
  
  $page->setCellValueByColumnAndRow(3,$j,$line4["middlename"]);
  
  $page->setCellValueByColumnAndRow(4,$j,$line4["adress"]);

  if (isset($_POST["c5"]) && (!empty($_POST["c5"]))){
  $page->setCellValueByColumnAndRow(5,$j,$line4["birth"]);
  }
  if (isset($_POST["c6"]) && (!empty($_POST["c6"]))){	
  $page->setCellValueByColumnAndRow(6,$j,$line4["sex"]);
  }
  if (isset($_POST["c7"]) && (!empty($_POST["c7"]))){
  $page->setCellValueByColumnAndRow(7,$j,$line4["nationality"]);
  }
  if (isset($_POST["c8"]) && (!empty($_POST["c8"]))){	
  $page->setCellValueByColumnAndRow(8,$j,$line4["marital"]);
  }
  $i=$i+1;
}
    $objWriter = PHPExcel_IOFactory::createWriter($phpexcel, 'Excel2007');
    $objWriter->save($file_name1);

  pg_free_result($result);

  pg_close($conn);

A
Alexander, 2015-05-15
@liff

Check doing:
1) Infinite loop in PHP
2) Check from console (cli) too
3) Increase for console (cli) memory php -D memory-limit=1G
4) Use lazy load data for writing/reading

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question