Re: Shutdown Memory Allowance (aka Soft Memory Limit)
| From: | Nikita Popov | Date: | Tue, 24 Sep 2019 16:50:35 +0000 |
| Subject: | Re: Shutdown Memory Allowance (aka Soft Memory Limit) | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-107315@lists.php.net to get a copy of this message | ||
On Tue, Sep 24, 2019 at 6:42 PM Dan Ackroyd <Danack@basereality.com> wrote:
> On Tue, 24 Sep 2019 at 07:26, Peter Stalman <sarkedev@gmail.com> wrote:
> >
> > So I would like to suggest an option for setting a shutdown memory
> allowance,
> > which would be the amount of additional memory allowed to be used by any
> > registered error handlers or shutdown functions.
>
> I can see the need, and what problem you're trying to solve. I think
> focusing on 'memory to be used by shutdown handlers' is slightly more
> specific than a solution needs to be.
>
> Just expressing it as, when PHP fails to allocate some memory due to
> reaching the limit then:
>
> * Increase the memory limit by an ini setting defined amount. This
> only happens once per request/process.
> * Throw an EngineException.
>
> should cover what you want to do, without tying the solution to where
> that memory can be used.
>
> One of the reasons I haven't submitted an RFC for that already is that
> I'm not sure what would be involved in making sure it was safe to
> throw an exception from places where the memory allocation could fail.
>
Throwing an exception on allocation failure is not possible. You could do
the same while keeping a fatal error though.
Nikita
> FYI possibly of interest, I did some investigation of a related
> feature a while ago, allowing people to trigger callbacks when the
> memory limit was reached:
> https://github.com/Danack/MemTrigger which is terribly out of
> date and
> a bad approach anyway, due to the performance hit, and people only
> really caring about hitting the memory limit.
>
> cheers
> Dan
> Ack
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>