我正在使用symfony 1.4 + propel 1.6,我想将所有用户数据库导出(索引)到ElasticSearch.
我写了所有的脚本,除了一个问题外,一切正常.我创建一个重复大约20.000次的循环,每次memory_usage增加.
问题是:它不应该,因为我正在摧毁所有的引用.
我认为Propel正在为我创建的每个对象留下静态引用.但是找不到它,因为我已经禁用了实例池.
有人遇到过类似的问题吗?也许有人知道如何调试PHP内存限制?(webgrind不)我花了最后几个小时在这段代码调试上仍然无法修复它.
// optimizations
gc_enable();
Propel::getConnection()->useDebug(false);
Propel::disableInstancePooling();
// the while
$offset = 0;
$perpage = 10;
$c = SearchUserQuery::create()->limit($perpage);
do {
$rs = SearchUserPeer::doSelectStmt($c);
while ($row = $rs->fetch(PDO::FETCH_NUM))
{
$instance = new SearchUser();
$instance->hydrate($row);
$data = $instance->toElastic(); // this line makes a lot of memory leak
$_document = new Elastica\Document($instance->getPrimaryKey(), $data);
$_type->addDocument($_document);
unset($_document, $instance);
}
$c->offset($offset += $perpage);
} while( $rs->rowCount() );
Run Code Online (Sandbox Code Playgroud)
函数$ instance-> toElastic就像这样:
public function toElastic()
{
return Array(
'profile' => …Run Code Online (Sandbox Code Playgroud) 我有一个非常奇怪的情况:下面显示的代码应该在PHP中不打印错误.
try {
throw new Exception('foo');
} catch(Exception $e) {
// here could be some custom functions to handle errors
die();
}
Run Code Online (Sandbox Code Playgroud)
在我的电脑上打印
( ! ) SCREAM: Error suppression ignored for
( ! ) Exception: foo. in D:\wamp\www\index.php on line 4
Run Code Online (Sandbox Code Playgroud)
为什么?哪个php ini选项可以做到这一点?