PHPExcelはかなりのメモリに
を割り当てます。
<?php
require_once 'php/PHPExcelSVN/PHPExcel/IOFactory.php';
$objPHPExcel = PHPExcel_IOFactory::load("php/tinytest.xlsx");
$objPHPExcel->setActiveSheetIndex(0);
$objPHPExcel->getActiveSheet()->setCellValue('D2', 50);
echo $objPHPExcel->getActiveSheet()->getCell('D8')->getCalculatedValue() . "
";
echo date('H:i:s') . " Peak memory usage: " . (memory_get_peak_usage(true)/1024/1024) . " MB\r\n";
?>
I get 6MB of memory usage.
別user even failed with a 256MByte memory設定:
this threadによれば、わずか5細胞を6メガバイトのメモリ使用量のをレンダリングしてもよいです。
PHPExcelはメモリフットプリントを減らす方法を提供しますが、私の場合はすべての削減が小さすぎることが判明しました。 This page on githubは、PHPExcelのキャッシュ管理オプションの詳細を提供します。たとえば、この設定は、ワークシートのセル構造をシリアライズし、GZIPs:私はPHPExcelをインストルメントPHP Excelの
Fatal error: Allowed memory size of xxx bytes exhausted (tried to allocate yyy bytes) in zzz on line aaa
PHPExcel holds an "in memory" representation of a spreadsheet, so it is susceptible to PHP's memory limitations. The memory made available to PHP can be increased by editing the value of the memorylimit directive in your php.ini file, or by using iniset('memory_limit', '128M') within your code (ISP permitting);
Some Readers and Writers are faster than others, and they also use differing amounts of memory. You can find some indication of the relative performance and memory usage for the different Readers and Writers, over the different versions of PHPExcel, here http://phpexcel.codeplex.com/Thread/View.aspx?ThreadId=234150
If you've already increased memory to a maximum, or can't change your memory limit, then this discussion on the board describes some of the methods that can be applied to reduce the memory usage of your scripts using PHPExcel http://phpexcel.codeplex.com/Thread/View.aspx?ThreadId=242712
測定結果
:
$cacheMethod = PHPExcel_CachedObjectStorageFactory::cache_in_memory_gzip;
PHPExcel_Settings::setCacheStorageMethod($cacheMethod);
PHPExcel's FAQはこれを説明します例ファイル[01simple.php][5]
とのクイックテストを実行しました。各フラグメントは約4メガバイトを消費し、1本のフラグメント数回変更せずに実行した場合
for($n=0; $n<200; $n++) {
$objPHPExcel->setActiveSheetIndex(0) ->setCellValue('A' . $n, 'Miscellaneous glyphs');
$objPHPExcel->getActiveSheet()->getStyle('A' . $n)->getAlignment()->setWrapText(true);
}
:
for($n=0; $n<200; $n++) {
$objPHPExcel->setActiveSheetIndex(0) ->setCellValue('A' . $n, 'Miscellaneous glyphs');
}
が4164キロバイトを消費:
は92キロバイトを消費します。
あなたのアプリをチェックする論理的に正しいです
確保するために、あなたのアプリケーションが論理的に正しいことを、私は最初のPHPのメモリ容量を増やすことを提案したい:
ini_set('memory_limit', '32M');
を私の場合、私がしなければなりませんエクスポートして、オンライン評価アプリケーションの結果データをエクスポートします。水平方向に100個未満のセルがあるのに対し、私はいくつかの10.000行までエクスポートする必要があります。セルの量が大きかったのに対し、私のセルはそれぞれ、数式または3文字の文字列を保持しています。数式はなく、スタイルはありません。
強いメモリ制限や、大きなスプレッドシート私の場合は
の場合は、キャッシュオプションのどれもが同じくらい必要に応じて量を削減しませんが。さらに、アプリケーションの実行時間が非常に長くなりました。
最後に、旧式のCSVデータファイルの書き出しに切り替える必要がありました。
/Examplesフォルダを使用している私たちのデモスクリプトの数20種類以上の異なるスタイルで、この問題を示すコードの実例を提供してください。問題は、いくつかのスタイルの後ではなく、設定している特定のスタイルにある可能性があります。 –
あなたの質問には '$ this'とは何ですか?あなたの質問には' $ coords'とは何ですか?問題を再現するための最低限の例はどこにありますか? http://meta.stackexchange.com/questions/22754/sscce-how-to-provide-examples-for-programming-questions – hakre