次のphpスクリプトを実行してローカルマシンで統計を実行すると、、でうまく機能しますinit_set('memory_limit', 100M)
。
ただし、同じphpスクリプトを別のWebサーバーで実行し、同じファイルを処理すると(これについては確信しています)、機能しません。
memory_limitを1000Mに変更しましたが、それでも機能せず、例外が発生します:「致命的なエラー:許可されたメモリサイズ1048576000バイトが使い果たされました(32バイトを割り当てようとしました)」。最後に私はに変更しますinit_set('memory_limit', 1300M)
、それは動作します!
2つのmahchineのphpバージョンは次のものと同じです:
PHP 5.3.6 (cli) (built: Mar 28 2012 02:18:34)
Copyright (c) 1997-2011 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies
with eAccelerator v0.9.6.1, Copyright (c) 2004-2010 eAccelerator, by eAccelerator
主なスクリプトは次のとおりです。
protected function _insertTable($logType, $conf, $logFileName) {
$logPath = $this->_getLogDirPath($logType, $conf) . DIRECTORY_SEPARATOR . $logFileName;
$fileContent = file_get_contents($logPath);
if ( !fileContent ) return;
$fields = array_keys($conf['fields']);
$dao = new dao\StatLogDao($this->_entities[$logType]);
$lines = explode("\n", $fileContent);
$fileContent = null;
unset($fileContent);
foreach ( $lines as $line ) {
$line = trim($line);
if ( !$line ) continue;
$lineData = explode($conf['glue'], $line);
if ( !$lineData[0] ) continue;
$entity = $this->_getEntity($logType);
foreach ($fields as $k => $f) {
$entity->$f = $lineData[$k];
}
try {
$dao->replace($entity, $fields);
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
$entity = null;
unset($entity);
$line = null;
unset($line);
}
$lines = null;
unset($lines);
$dao = null;
unset($dao);
}
私は完全に混乱しています。「unset」では十分なメモリが解放されないようです。plzが私を助けてくれます。どうもありがとう!!