Bug #78076 [Com]: Opcache greatly increases memory usage.

From: Date: Tue, 28 May 2019 15:09:32 +0000
Subject: Bug #78076 [Com]: Opcache greatly increases memory usage.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-221029@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=78076&edit=1 ID: 78076 Comment by: tyler dot bannister at remote-learner dot net Reported by: tyler dot bannister at remote-learner dot net Summary: Opcache greatly increases memory usage. Status: Feedback Type: Bug Package: opcache Operating System: Centos 7.4.1708 PHP Version: 7.1.29 Assigned To: cmb Block user comment: N Private report: N New Comment: I was able to confirm the problem also exists in PHP 7.2.18. Previous Comments: ------------------------------------------------------------------------ [2019-05-28 10:24:32] cmb@php.net PHP 7.1 receives only security fixes. Can you reproduce the issue with any of the actively supported PHP versions[1]. [1] <https://www.php.net/supported-versions.php> ------------------------------------------------------------------------ [2019-05-27 21:28:19] tyler dot bannister at remote-learner dot net Related To: Bug #76982 ------------------------------------------------------------------------ [2019-05-27 21:25:07] tyler dot bannister at remote-learner dot net Description: ------------ Using the database install script for Moodle 3.2, 3.3, 3.4, 3.5 or Totara 10, 11 or 12 with PHP 7.1.28 or 7.1.29 when opcache is turned on the script runs out of memory even if the memory limit is increased to 2 GB, when opcache is turned off the script uses 78 MB of memory, when opcache is turned on it ran out of memory with 2 GB of memory allowed, at 4 GB of memory the script was killed before it could complete but it looked like it was using all of that memory before it was killed. I suspect that issue is that during installation the Moodle install script does something incredibly stupid, it turns off caching of language strings (it's multi-language system) which means every time it needs to print a message it includes the file that contains the string. Over the course of the database install it ends up including each file hundreds of times and with or without opcache enabled each of those includes seems to increase the amount of memory used, but with opcache enabled the memory usage grows much faster. I've written a pair of simple test scripts to illustrate this behaviour. Test script: --------------- test1.php: <?php print("Starting Memory:". memory_get_usage() ."\n"); for ($x = 1; $x < 10000; $x += 1) { include("test2.php"); } print("Ending Memory:". memory_get_usage() ."\n"); test2.php: <?php $a = "Hello World!\n"; Expected result: ---------------- When test1.php and test2.php are placed in the same directory and the scrits are run with opcache enabled and opcache disabled they should produce roughly the same starting and ending memory sizes. Actual result: -------------- Opcache disabled: Starting Memory:349712 Ending Memory:349872 Opcache enabled: Starting Memory:348856 Ending Memory:7820120 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=78076&edit=1

« previous php.bugs (#221029) next »