Closed zacksleo closed 5 years ago
Swoole是常驻进程的, 传统框架或组件很容易出现全局变量或静态变量不断积累导致PHP内存达到上限, 应该和rawContent
无关, 检查你是否清理了相关全局变量内存.
将传统框架和组件直接移植到swoole是危险重重的, 不建议这么做.
还有好像这个包长得不太对, 不符合HTTP规范
swoole 新的框架感觉都不成熟,另外这是实验性项目,从原有的框架上尝试进行迁移测试。哪里不符合规范?
https://github.com/zacksleo/yii2-swoole/blob/refactor-swoole/src/console/SwooleController.php#L144
类似问题如何进行排除,查找原因呢
完善了下代码,如下形式可以了
private $_rawBody;
/**
* @inheritdoc
*/
public function getRawBody()
{
if ($this->_rawBody === null) {
$this->_rawBody = $this->swooleRequest->rawContent();
}
return $this->_rawBody;
}
https://github.com/zacksleo/yii2-swoole/commit/f526e35e81814a9958b7e525aef0dc379676b8a5
1. What did you do? If possible, provide a simple script for reproducing the error.
重写 Yii2 中的 request 组件中的 getRawBody 方法
2. What did you expect to see?
request
output
string(20) "{ "hello":"world" }"
3. What did you see instead?
调用时出现
Allowed memory size of 1073741824 bytes exhausted (tried to allocate 1634692240 bytes
4. What version of Swoole are you using (show your
php --ri swoole
)?4.2.3
5. What is your machine environment used (including version of kernel & php & gcc) ?