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

From: Date: Tue, 05 May 2020 09:25:23 +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-226919@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:         jerome dot vieilledent at blackfire dot io
 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:

Hi there,

Here are 2 profiles for comparison:

- PHP 7.3.17: https://blackfire.io/profiles/b7785fda-415f-4176-a57e-f5e2417b46b0/graph
- PHP 7.4.5: https://blackfire.io/profiles/712b3b08-4ccc-4a6a-ae9b-70b4ee030334/graph
- Comparison graph:https://blackfire.io/profiles/compare/b7785fda-415f-4176-a57e-f5e2417b46b0...712b3b08-4ccc-4a6a-ae9b-70b4ee030334/graph

You have access to the timeline which shows the peak memory increasing (blue graph in the
background).
While exploring the comparison graph a bit, using the memory dimension, I found that it looks like
it's coming from explode()/implode()/array_shift():
- https://blackfire.io/profiles/compare/b7785fda-415f-4176-a57e-f5e2417b46b0...712b3b08-4ccc-4a6a-ae9b-70b4ee030334/graph?settings%5Bdimension%5D=pmu&settings%5Bdisplay%5D=focused&settings%5BtabPane%5D=nodes&selected=Faker%5CProvider%5CText%3A%3AgetConsecutiveWords%3F00a7bff87618e1493437abb5cf94878a&callname=Faker%5CProvider%5CText%3A%3AgetConsecutiveWords%3F00a7bff87618e1493437abb5cf94878a
- https://blackfire.io/profiles/compare/b7785fda-415f-4176-a57e-f5e2417b46b0...712b3b08-4ccc-4a6a-ae9b-70b4ee030334/graph?settings%5Bdimension%5D=pmu&settings%5Bdisplay%5D=focused&settings%5BtabPane%5D=nodes&selected=Faker%5CProvider%5CText%3A%3AgetExplodedText%3F00a7bff87618e1493437abb5cf94878a&callname=Faker%5CProvider%5CText%3A%3AgetExplodedText%3F00a7bff87618e1493437abb5cf94878a

I hope this helps :-)


Previous Comments:
------------------------------------------------------------------------
[2020-04-30 12:11:59] kieran at miami-nice dot co dot uk

https://github.com/bytestream/php74-memory-leak/tree/routes

$ ~/php7.4.6-rc.1/bin/php -d memory_limit=-1 vendor/bin/phpunit --repeat 1000
Time: 42.64 seconds, Memory: 520.00 MB

https://github.com/bytestream/php74-memory-leak/tree/factories

$ ~/php7.4.6-rc.1/bin/php -d memory_limit=-1 vendor/bin/phpunit --repeat 100
Time: 3.37 minutes, Memory: 1.45 GB

Another leak? Memory usage up in both cases compared to 7.4.5

------------------------------------------------------------------------
[2020-04-30 11:56:18] cmb@php.net

Please tests with PHP 7.4.6RC1 (has just been released).

------------------------------------------------------------------------
[2020-04-30 11:37:33] maggus dot staab+php at gmail dot com

Could it be related to the recently fixed leak 

https://github.com/php/php-src/commit/3151676f520555bfadb39ea76779e93552d13fc1

------------------------------------------------------------------------
[2020-04-28 17:33:12] kieran at miami-nice dot co dot uk

It's something to do with the use of require

Another example, different code, but same principle. 

https://github.com/bytestream/php74-memory-leak/tree/factories

$ php7.2 vendor/bin/phpunit --repeat 100
Time: 1.75 minutes, Memory: 322.00 MB

$ php7.3 vendor/bin/phpunit --repeat 100
Time: 1.02 minutes, Memory: 310.50 MB

$ php7.4 vendor/bin/phpunit --repeat 100
Time: 2.24 minutes, Memory: 1.32 GB

------------------------------------------------------------------------
[2020-04-28 16:27:56] kieran at miami-nice dot co dot uk

Adding more routes to the test case seems to show some interesting results.

https://github.com/bytestream/php74-memory-leak/tree/routes

$ php7.2 vendor/bin/phpunit --repeat 1000
Time: 1.09 minutes, Memory: 144.00 MB

$ php7.3 vendor/bin/phpunit --repeat 1000
Time: 17.47 seconds, Memory: 138.00 MB

$ php7.4 vendor/bin/phpunit --repeat 1000
Time: 58.73 seconds, Memory: 510.00 MB

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


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 (#226919) next »