[php-src] Issue #7944: api to set memory_limit to "at least" this much
| From: | KapitanOczywisty | Date: | Tue, 18 Jan 2022 19:44:46 +0000 |
| Subject: | [php-src] Issue #7944: api to set memory_limit to "at least" this much | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-239111@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/7944
Comment Author: KapitanOczywisty
> wonder how "unlimited" would be represented in such a function tho, should it return
> -1 for no limit? or null?
PHP uses
int|null or int|false in similar cases.
> Wouldn't it be better, if there was a way to retrieve the currently set memory limit as
> _number_?
This will help OP, but I wonder if there is a chance to add callback for when ini settings are
changed, this would allow to control what libraries are doing and in this case control memory limit.
ini_changed(string $name, callback $value); with $value = fn($old_value,
$new_value)=>$new_value.
Also ini_set supposed to return false on failure, but if you try setting ridiculous
value like ini_set('memory_limit', '2K') you'll get old value,
and ini_get will return 2K, but limit remains unchanged - limit cannot be
lower than currently allocated.
[/main/main.c#L261-L283](https://github.com/php/php-src/blob/20d8561ed4986c3ca1e514b7bcb2dda8b6fbe0ee/main/main.c#L261-L283)
[/Zend/zend_alloc.c#L2669-L2678](https://github.com/php/php-src/blob/20d8561ed4986c3ca1e514b7bcb2dda8b6fbe0ee/Zend/zend_alloc.c#L2669-L2678)