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
PHP 8.1 Failed to set memory limit to ... bytes (Current memory usage is ... bytes) #8116
Comments
Not sure if it helps, but you could try setting |
Thanks for feedback. I cannot change values in It is really hard to nail it. Out of 5000 requests we had it currently happen only a few times. I would understand if at that point, the system memory is probably too low to allocate this memory, but the error says that it is already using over |
Furthermore, the funny thing is, the initial memory limit from php.ini is just |
I think this behavior is caused by fixing https://bugs.php.net/bug.php?id=81585 (PHP 8.0.15 and 8.1.2); there has been a follow up fix that should be in PHP 8.0.17 and 8.1.4. Unfortunately, there are no snapshot builds for Windows currently, so you either have to build yourself, or wait for PHP 8.1.4RC1 (expected on 2022-03-03) to verify. |
@cmb69 Looks somewhat similar yes but isn't there a other problem with this? Because the initial limit is TLDR: When having |
Thanks to https://bugs.php.net/bug.php?id=81585 an the posted test script, i've created a testscript that can now be reproduced. The error is similar, but not quite the same, i guess? Just call it 2 times in your browser, the first time, it just runs fine, second time, it fails. Output first call:
Output second call:
Hope this helps |
The script works as expected (at least with the built-in Webserver) with current PHP-8.1 head. I still think the mentioned follow up fix is responsible for that. |
Ok, i will test when a 8.1.4 windows build is available. |
With the new 8.1.4 RC1 build from https://phpdev.toolsforresearch.com/php-8.1.4RC1-Win32-vs16-x64.zip i can verify that this error is gone. |
So I'm closing this ticket. |
Currently using 8.1.8 (just upgraded few days ago), and this issue is still happening. Difference is that the server is originally 128M. We will sometimes get the below warning (not always replicable, even downloading the same pdf file might not always have the warning). Severity: Warning --> Failed to set memory limit to 134217728 bytes (Current memory usage is 3557695488 bytes) PHP Version 8.1.8 |
This is not really well suited to the current ZendMM behavior, since it keeps some of the memory allocated, to avoid frequent reallocations.
And that is the result of that ZendMM behavior. I don't think there is anything to fix in the engine; consider to silence the warning ( |
Before i proceed with this, just wanting to know, is there any downsides/dangers of this behavior? Will there be memory leak issues or it should be fine as long as this warning is encountered at the very end of the script? |
I guess, setting the limit higher in a script and then lower it again in the same script will make no sense. So i would recommend never decrease the limit at runtime, only increase if needed, to avoid those kind of errors. Memory is freed automatically on script termination but may still be hold during the script once it has been taken. Decrease will then result in your kind of error here. Anyway, i think that this thread is not the correct place to discuss this further @patrickteng , because this issue here is not your issue. Just to avoid off-topic. |
I believe we need to narrow down the culprit here where it'd Wordpress or php. As far php have tried both 8.1 and 8.2, same thing.
2.themes.php%3Fpage%3Dsimple-custom-css.php This issue has been logged with Wordpress here; |
Got it Failed to set memory limit to so if using apache all you have already taken care of: all you have to do is ensure. And walla, you will upload larger images, you will also won't have issues with like events posts, etc |
|
Description
Hi!
We recently upgraded to PHP 8.1 and now we sporadically get this kind of new errors:
Failed to set memory limit to 536870912 bytes (Current memory usage is 870318080 bytes)
The problem is, the memory usage cannot be that high at that moment, because we use
ini_set
on the very start of the script, where almost nothing happened.Furthermore, we can call the same page 100x times, the error does not appear, but sometime, it happens. It is impossible to reproduce. It definitely only is on PHP 8.1 - With PHP 8.0 we never had this kind of issues.
I guess that the system has sometimes wrong internal memory usage stats, maybe from another thread on the same system?
Is there something we can do about it, without just error suppressing or try/catch?
We are on Windows Server, with Apache 2.4.52 and PHP 8.1.2 TSx64.
As said above, unfortunately i have no reproducible example, but the code that throw the error is this line
ini_set("memory_limit", "512M");
Edit: Have now a reproducible script at #8116 (comment)
PHP Version
PHP 8.1.2 TSx64
Operating System
Windows Server 2019
The text was updated successfully, but these errors were encountered: