Bug #79519 [Com]: Memory leak in PHP 7.4

From: Date: Mon, 10 Aug 2020 20:19:32 +0000
Subject: Bug #79519 [Com]: Memory leak in PHP 7.4
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-228496@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=79519&edit=1

 ID:                 79519
 Comment by:         kieran at supportpal dot com
 Reported by:        kieran at miami-nice dot co dot uk
 Summary:            Memory leak in PHP 7.4
 Status:             Open
 Type:               Bug
 Package:            Performance problem
 Operating System:   Linux
 PHP Version:        7.4.5
 Block user comment: N
 Private report:     N

 New Comment:

Will there be a fix for this issue in PHP 8? Just tested against the PHP 8.0-beta.1 docker image and
memory usage matches PHP 7.4


Previous Comments:
------------------------------------------------------------------------
[2020-05-21 19:32:20] kieran at supportpal dot com

@nikita I think you're probably right:
> PHP 7.4 fixed some issues related to anonymous functions "overwriting" previous
> anonymous functions in the same file

I "memorised" the faker requires as suggested and it cut usage from 3.8G to 2.6G. So I
assume similar changes elsewhere would further reduce memory usage. The only problem is anonymous
function usage is rife in Laravel!

Not sure if you want to close this as duplicate of https://bugs.php.net/bug.php?id=76982 or repurpose
following below comment:
> The master branch case is still potentially actionable from our side.

------------------------------------------------------------------------
[2020-05-15 10:58:59] nikic@php.net

I see. The master branch case is still potentially actionable from our side. The problem there is
that GC runs too rarely. PHP 7.4 made this worse, because collecting objects with destructors
requires two GC runs, and is seems Laravel makes use of destructors somewhere in there.

There's probably two things we can do to improve this at least:
1. Count any GC run with destructors as a "successful" run, so threshold is reduced.
2. Allow threshold reductions below the default of 10000, which seems too high for this case.

Alternatively we could always automatically rerun GC if we encountered destructors, instead of
waiting for the next GC run.

------------------------------------------------------------------------
[2020-05-15 10:53:42] kieran at supportpal dot com

Can ignore the master branch. That was an issue in Laravel that I pushed a fix for. I've just
not updated that repository yet.

------------------------------------------------------------------------
[2020-05-15 10:45:39] nikic@php.net

It looks like the cause for the "routes" case is the same. However, the "master"
branch is a different issue. Here are the massif outputs for 7.3 and 7.4: https://gist.github.com/nikic/2a5d1a6eb4a4bb82be5e18225ae16d87

------------------------------------------------------------------------
[2020-05-15 09:22:42] nikic@php.net

@kieran: PHP 7.4 fixed some issues related to anonymous functions "overwriting" previous
anonymous functions in the same file under some circumstances. Unfortunately this also means that
this leak is now more pronounced, because this accidental destruction vector no longer exists.

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=79519


--
Edit this bug report at https://bugs.php.net/bug.php?id=79519&edit=1


Thread (25 messages)

« previous php.bugs (#228496) next »