8000 Not enough reserved memory in debug component's ErrorHandler · Issue #26893 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Not enough reserved memory in debug component's ErrorHandler #26893

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
krixon opened this issue Apr 11, 2018 · 8 comments
Closed

Not enough reserved memory in debug component's ErrorHandler #26893

krixon opened this issue Apr 11, 2018 · 8 comments

Comments

@krixon
Copy link
krixon commented Apr 11, 2018
Q A
Bug report? yes
Feature request? no
BC Break report? no
RFC? no
Symfony version 3.4.5

Upon reaching the configured memory_limit, I get a fatal error from the Debug component as it tries to handle the error. For example:

Fatal error:  Allowed memory size of 67108864 bytes exhausted (tried to allocate 28672 bytes) in /var/www/vendor/symfony/symfony/src/Symfony/Component/Debug/ExceptionHandler.php on line 239

I can fix this by increasing the amount of reserved memory in Symfony\Component\Debug\ErrorHandler:

self::$reservedMemory = str_repeat('x', 20480);

This allows the error handling process to complete and the OutOfMemoryException is thrown as expected, but there is currently no way to configure this value.

@nicolas-grekas
Copy link
Member

Would you like opening a PR doing so? Doubling the amount of reserved memory looks reasonable to me (did you try any lower value btw?)

8000
@krixon
Copy link
Author
krixon commented Apr 23, 2018

did you try any lower value btw?

I've been trying a few different values and I'm actually seeing very inconsistent results. Making the same request sometimes works with as low as 10240 reserved bytes but sometimes even 64K isn't enough to make it all the way through the ExceptionHandler. Other times a value somewhere in between works fine.

I'm reluctant to open a PR without understanding why requests are varying so much in terms of memory usage when they are ostensibly identical, so I will try to set up a simple, reproducible example using a fresh clone first.

@nicolas-grekas
Copy link
Member

Could you also check if calling gc_collect_cycles() while releasing the reserved memory helps?

@nicolas-grekas
Copy link
Member

@krixon shall we close then?

@krixon
Copy link
Author
krixon commented Jun 19, 2018

Sorry, I haven't had time to progress this. I am happy to close, I will reopen if I get to a point where I can reproduce this reliably.

@krixon krixon closed this as completed Jun 19, 2018
@jinraynor1
Copy link

Hi, i am using PHP 5.3.3 and loading exception for OutOfMemory exceeds reservedMemory variable, the following snippets prints in my server 46368, look at this example:

$a = memory_get_usage();
include_once 'vendor/symfony/debug/Symfony/Component/Debug/Exception/FatalErrorException.php';
include_once 'vendor/symfony/debug/Symfony/Component/Debug/Exception/OutOfMemoryException.php';
$c = new \Symfony\Component\Debug\Exception\OutOfMemoryException("dummy",1,1,1,1,1);

$b = memory_get_usage();
var_dump($b- $a); // it prints 46368 bytes
exit;

If you attach a logger via method setDefaultLogger then you also need to increase the reservedMemory to your own needs.

I have tried to extend the class and init my own reserved memory with no luck as the ErrorHandler class registers the shutdown function in a no extendable way

register_shutdown_function(__CLASS__.'::handleFatalError');

My ugly solution is copy the all ErrorHandler class and add my own constant :(

self::$reservedMemory = str_repeat('x', MEMORY_RESERVED_ERROR_HANDLER);

@jinraynor1
Copy link

I have created a pull request symfony/debug#8

@sakalys
Copy link
Contributor
sakalys commented Nov 29, 2021

Hi all, this should get fixed in symfony 4.4 soon, as there is a merged in PR for that #44327

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants
0