ini_set('memory_limit', '1G');
$gmworker= new GearmanWorker();
$gmworker->addServer();
$gmworker->addFunction("create_job_process", "worker_create_job");
$gmworker->setTimeout(-1);
print "Waiting for job...\n";
while($gmworker->work())
{
if ($gmworker->returnCode() != GEARMAN_SUCCESS)
{
echo "return_code: " . $gmworker->returnCode() . "\n";
break;
}
if ($gmworker->returnCode() == GEARMAN_SUCCESS)
{
echo "success\n\n";
break;
}
sleep(1);
}
当日志中显示“成功”时,我可以看到内存使用量在增长,然后出现错误:
PHP致命错误:允许的内存大小为1073741824字节已用尽(试图分配24字节)