The PHPExcel class memory usage problem recently helped a company export the background excel function. The tool class is phpexcel, because this class has powerful and comprehensive functions. However, the following problem occurs in [this article comes from Internet of Hong Kong (www.68idc.cn)]: When the exported data volume reaches a certain magnitude, for example, 1000 entries
The PHPExcel class memory usage problem recently helped a company export the background excel function. The tool class is phpexcel, because this class has powerful and comprehensive functions. But encountered [this article from the Internet (http://www.68idc.cn)] the following problem: when the export data volume reached a certain order of magnitude, such as 1000, the server
Memory usage in PHPExcel
Recently, I was helping a company export back-end excel Data Using phpexcel, Which is powerful and comprehensive.
But encountered [this article from the Internet (http://www.68idc.cn)] the following problem:
When the exported data volume reaches a certain order of magnitude, for example, 1000 entries, the server may be stuck or white screen. If you increase the export volume, the 502 error gateway prompt will appear.
After investigation by Baidu and some domestic forums,
The following measures are taken:
1. Set PHP Cache
// Set the cache method PHPExcel_Settings: setCacheStorageMethod ();
2. Set the maximum execution time
// Set the maximum execution time set_time_limit (0 );
But after debugging, it does not work and still reports the 502 error.
Finally, after checking the memory information, I switched the root cause of the problem to the memory, so I made the following settings:
// Set the memory limit ini_set ('memory _ limit ', '256m ');
The following is an exciting result. excel has been exported successfully!
So far, the problem has been solved.
Phpexcel is indeed a powerful class, but it has a lot of room for improvement in performance optimization. I hope to launch a lightweight excel class in the near future. ^_^