Tib*_*bor 5 memory-leaks rabbitmq symfony monolog
我在 Symfony2(兔子消费者)中有一个长时间运行的进程,我正在使用MonologBundle进行日志记录。这些行会立即记录下来,但我注意到进程的内存消耗随着每次迭代而增加,几分钟后达到 1GB 以上。
脚本运行:--env=prod
所以我做了一个较小的测试:
// taken from my symfony test command
$logger = $this->getContainer()->get('logger');
while (true){
$logger->debug("line one");
$logger->debug("line two");
$logger->debug("line three");
var_dump($logger);
}
Run Code Online (Sandbox Code Playgroud)
这是大约 10k 次迭代后的 var_dump 内容:
class Symfony\Bridge\Monolog\Logger#3 (3) {
protected $name =>
string(3) "app"
protected $handlers =>
array(1) {
[0] =>
class Monolog\Handler\FingersCrossedHandler#132 (11) {
protected $handler =>
class Monolog\Handler\StreamHandler#133 (9) {
...
}
protected $activationStrategy =>
class Monolog\Handler\FingersCrossed\ErrorLevelActivationStrategy#134 (1) {
...
}
protected $buffering =>
bool(true)
protected $bufferSize =>
int(0)
protected $buffer =>
array(100) {
...
}
protected $stopBuffering =>
bool(true)
protected $passthruLevel =>
NULL
protected $level =>
int(100)
protected $bubble =>
bool(true)
protected $formatter =>
NULL
protected $processors =>
array(0) {
...
}
}
}
protected $processors =>
array(0) {
}
}
Run Code Online (Sandbox Code Playgroud)
Monolog 捆绑设置:
monolog:
handlers:
main:
type: fingers_crossed
action_level: error
handler: nested
buffer_size: 100
nested:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.log"
level: debug
buffer_size: 100
framework:
profiler:
only_exceptions: false
enabled: false
collect: false
Run Code Online (Sandbox Code Playgroud)
缓冲区中的日志条目没有超过 buffer_limit 但脚本的内存使用量仍然增加。
有任何想法吗?谢谢
PS:我用普通的 monolog 重复了测试,没有内存问题。