Unusual Memory Usage during Save

Topics: Developer Forum
Feb 19, 2010 at 11:47 PM

Hello, I am trying to use PHPExcel to generate an Excel report, but during Saving it blows up in memory.

I am writing 13 sheets with data in each of about 20 columns and 65 rows (give or take) for about 15000 cells of data (mostly zeros).

I've created an error log of sorts to show me the memory as the script runs. The last mem-usage line doesn't show because the script crashes, but I've allowed PHP about 332 Mb and it's still not enough. What's going on?

 

[Fri Feb 19 15:43:15 2010] [notice] Apache/2.2.14 (Win32) PHP/5.3.1 DAV/2 configured -- resuming normal operations
[Fri Feb 19 15:43:15 2010] [notice] Server built: Sep 28 2009 22:41:08
[Fri Feb 19 15:43:15 2010] [notice] Parent: Created child process 3820
[Fri Feb 19 15:43:16 2010] [notice] Child 3820: Child process is running
[Fri Feb 19 15:43:16 2010] [notice] Child 3820: Acquired the start mutex.
[Fri Feb 19 15:43:16 2010] [notice] Child 3820: Starting 250 worker threads.
[Fri Feb 19 15:43:16 2010] [notice] Child 3820: Starting thread to listen on port 80.
[Fri Feb 19 15:43:22 2010] [error] [client 127.0.0.1] Current Sheet Index: 1, referer: http://localhost/FNF.php
[Fri Feb 19 15:43:22 2010] [error] [client 127.0.0.1] Stake Name: Corona_Ward, referer: http://localhost/FNF.php
[Fri Feb 19 15:43:23 2010] [error] [client 127.0.0.1]  Peak memory usage: 8.75 MB, referer: http://localhost/FNF.php
[Fri Feb 19 15:43:23 2010] [error] [client 127.0.0.1] Current Sheet Index: 2, referer: http://localhost/FNF.php
[Fri Feb 19 15:43:23 2010] [error] [client 127.0.0.1] Stake Name: Hemet_Ward, referer: http://localhost/FNF.php
[Fri Feb 19 15:43:24 2010] [error] [client 127.0.0.1]  Peak memory usage: 10 MB, referer: http://localhost/FNF.php
[Fri Feb 19 15:43:24 2010] [error] [client 127.0.0.1] Current Sheet Index: 3, referer: http://localhost/FNF.php
[Fri Feb 19 15:43:24 2010] [error] [client 127.0.0.1] Stake Name: Jurupa_Ward, referer: http://localhost/FNF.php
[Fri Feb 19 15:43:25 2010] [error] [client 127.0.0.1]  Peak memory usage: 11.25 MB, referer: http://localhost/FNF.php
[Fri Feb 19 15:43:25 2010] [error] [client 127.0.0.1] Current Sheet Index: 4, referer: http://localhost/FNF.php
[Fri Feb 19 15:43:25 2010] [error] [client 127.0.0.1] Stake Name: Menifee_Ward, referer: http://localhost/FNF.php
[Fri Feb 19 15:43:26 2010] [error] [client 127.0.0.1]  Peak memory usage: 12.75 MB, referer: http://localhost/FNF.php
[Fri Feb 19 15:43:26 2010] [error] [client 127.0.0.1] Current Sheet Index: 5, referer: http://localhost/FNF.php
[Fri Feb 19 15:43:26 2010] [error] [client 127.0.0.1] Stake Name: Moreno Valley_Ward, referer: http://localhost/FNF.php
[Fri Feb 19 15:43:27 2010] [error] [client 127.0.0.1]  Peak memory usage: 13.5 MB, referer: http://localhost/FNF.php
[Fri Feb 19 15:43:27 2010] [error] [client 127.0.0.1] Current Sheet Index: 6, referer: http://localhost/FNF.php
[Fri Feb 19 15:43:27 2010] [error] [client 127.0.0.1] Stake Name: Murrieta_Ward, referer: http://localhost/FNF.php
[Fri Feb 19 15:43:28 2010] [error] [client 127.0.0.1]  Peak memory usage: 15 MB, referer: http://localhost/FNF.php
[Fri Feb 19 15:43:28 2010] [error] [client 127.0.0.1] Current Sheet Index: 7, referer: http://localhost/FNF.php
[Fri Feb 19 15:43:28 2010] [error] [client 127.0.0.1] Stake Name: Palm Desert_Ward, referer: http://localhost/FNF.php
[Fri Feb 19 15:43:29 2010] [error] [client 127.0.0.1]  Peak memory usage: 16 MB, referer: http://localhost/FNF.php
[Fri Feb 19 15:43:29 2010] [error] [client 127.0.0.1] Current Sheet Index: 8, referer: http://localhost/FNF.php
[Fri Feb 19 15:43:29 2010] [error] [client 127.0.0.1] Stake Name: Redlands_Ward, referer: http://localhost/FNF.php
[Fri Feb 19 15:43:30 2010] [error] [client 127.0.0.1]  Peak memory usage: 17 MB, referer: http://localhost/FNF.php
[Fri Feb 19 15:43:30 2010] [error] [client 127.0.0.1] Current Sheet Index: 9, referer: http://localhost/FNF.php
[Fri Feb 19 15:43:30 2010] [error] [client 127.0.0.1] Stake Name: Riverside_Ward, referer: http://localhost/FNF.php
[Fri Feb 19 15:43:31 2010] [error] [client 127.0.0.1]  Peak memory usage: 18.25 MB, referer: http://localhost/FNF.php
[Fri Feb 19 15:43:31 2010] [error] [client 127.0.0.1] Current Sheet Index: 10, referer: http://localhost/FNF.php
[Fri Feb 19 15:43:31 2010] [error] [client 127.0.0.1] Stake Name: Temecula_Ward, referer: http://localhost/FNF.php
[Fri Feb 19 15:43:32 2010] [error] [client 127.0.0.1]  Peak memory usage: 19.5 MB, referer: http://localhost/FNF.php
[Fri Feb 19 15:43:32 2010] [error] [client 127.0.0.1] Current Sheet Index: 11, referer: http://localhost/FNF.php
[Fri Feb 19 15:43:32 2010] [error] [client 127.0.0.1] Stake Name: Yucaipa_Ward, referer: http://localhost/FNF.php
[Fri Feb 19 15:43:33 2010] [error] [client 127.0.0.1]  Peak memory usage: 20.5 MB, referer: http://localhost/FNF.php
[Fri Feb 19 15:43:33 2010] [error] [client 127.0.0.1] Current Sheet Index: 12, referer: http://localhost/FNF.php
[Fri Feb 19 15:43:33 2010] [error] [client 127.0.0.1] Stake Name: Yucca Valley_Ward, referer: http://localhost/FNF.php
[Fri Feb 19 15:43:34 2010] [error] [client 127.0.0.1]  Peak memory usage: 21.5 MB, referer: http://localhost/FNF.php
[Fri Feb 19 15:43:34 2010] [error] [client 127.0.0.1] Saving worksheet. Current Peak memory usage: 21.5 MB, referer: http://localhost/FNF.php
[Fri Feb 19 15:43:35 2010] [error] [client 127.0.0.1] Created Writer Excel2007, Execute Save operation. Current Peak memory usage: 22.5 MB, referer: http://localhost/FNF.php
[Fri Feb 19 15:43:48 2010] [error] [client 127.0.0.1] PHP Fatal error:  Allowed memory size of 348127232 bytes exhausted (tried to allocate 261904 bytes) in D:\\UniServer\\www\\Classes\\PHPExcel\\Calculation.php on line 2164, referer: http://localhost/FNF.php

What can I do?

 

Feb 20, 2010 at 12:43 AM

Ah! An epiphany! An error in a part of the script that writes a few functions (accidentally) wrote an indefinite circular reference, which caused the calculation engine to loop endlessly (and sucking up resources) as it tried to reach the end of the formula...

I guess circular reference checking should be added to the feature list?

Coordinator
Feb 21, 2010 at 10:25 AM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.