PHP Classes

Memory usage large files

Recommend this page to a friend!

      SimpleXLSX  >  All threads  >  Memory usage large files  >  (Un) Subscribe thread alerts  
Subject:Memory usage large files
Summary:How to improve memory usage
Messages:4
Author:John
Date:2012-07-25 13:13:02
Update:2012-12-13 17:52:50
 

  1. Memory usage large files   Reply   Report abuse  
Picture of John John - 2012-07-25 13:13:02
CAn you give some performance or memory handling tips when using large xlsx files (>10MB). Hitting memory problems en performance isn't that good either.
Using file with 100K lines.

Usage: need to get only data from file to input into database

Code:
[code]
$sheets = array();
$xlsx = new SimpleXLSX($inputFileName);
$getWorksheetName = $xlsx->getWorksheetName();

for ($j = 1; $j <= $xlsx->sheetsCount(); $j++) {
$sKey = strtoupper($getWorksheetName[$j - 1]);
// output worsheet 1
$cells = array();
list($cols, ) = $xlsx->dimension($j);
$counter = 1;
foreach ($xlsx->rows($j) as $r) {
for ($i = 0; $i < $cols; $i++) {
if (isset($r[$i])) {
$cellKey = $i + 1;
$cells[$counter][$cellKey] = $r[$i];
}
}
$counter++;
}
$sheets[$sKey] = array('numRows' => $counter, 'cells' => $cells);
}
unset($xlsx);
[/code]

  2. Re: Memory usage large files   Reply   Report abuse  
Picture of Sergey Shuchkin Sergey Shuchkin - 2012-07-26 03:46:25 - In reply to message 1 from John
see php.ini, try
memory_limit = 512M

* don't use shared hosting

  3. Re: Memory usage large files   Reply   Report abuse  
Picture of Anggie Aziz Anggie Aziz - 2012-11-07 04:45:04 - In reply to message 2 from Sergey Shuchkin
Hi sergey, I use ur simplexlsx class to read 38879 rows of data (on 1 sheet) and I had a problem with memory (Out of Memory). My server's memory size is 48 GIGS and I set the memory_limit (php.ini) on 9000MB, but the problem is still there! Can you tell me what I am supposed to do?

  4. Re: Memory usage large files   Reply   Report abuse  
Picture of Andre russowsky Andre russowsky - 2012-12-13 17:52:50 - In reply to message 3 from Anggie Aziz
Allowed memory size of 268435456 bytes exhausted (tried to allocate 1054721 bytes)

Tring on a 700kb xlsx and getting out of memory