bug: OOM errors on stream handler as of Monolog 2.3.0
bshaffer opened this issue · comments
Monolog version 2 (only on 2.3.0+)
Error: PHP Fatal error: Allowed memory size of 2147483648 bytes exhausted (tried to allocate 2147483647 bytes) in...
This can be recreated with the following file (note the php ini setting memory_limit=2048M
):
ini_set('memory_limit', '2048M');
$stream = tmpfile();
new Monolog\Handler\StreamHandler($stream);
stream_get_contents($stream);
@dwsupplee tracked the issue down to this change. When I remove the calls to stream_set_chunk_size
in the handler, the OOM error disappears.
I don't know the proper solution, if this change should just be reverted, or if we should do something to ensure the memory limit is less than the chunk size... maybe there's some specific handling necessary for tmpfile
? Either way, this is a pretty nasty error so any help is appreciated!
I Will create a PR during The morning... to propose a solution for this
The pull request is created but it cannot pass a phpstan test, and I dont know if is my change or something else.
Any help?
Should be fixed by #1578