memory usage increasing when using opcache.enable_cli and opcache.file_cache_only
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 40.4k
- Forks
- 8.2k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 96
Description
Description
The below script using opcache.enable_cli=1 and opcache.file_cache_only=1 causes the PHP memory usage to continue to increase. If I disable file_cache_only, then the memory usage remains constant. I was able to reproduce in PHP 8.1, 8.2, and 7.4.
To reproduce, set-up scripts test.php and test2.php as listed below, create an empty directory /tmp/opcache, and then run:
php \
-n \
-d "zend_extension=opcache" \
-d "opcache.enable_cli=1" \
-d "opcache.file_cache=/tmp/opcache" \
-d "opcache.file_cache_only=1" \
test.php
When I run the above, the value of memory_get_usage() continues to increase. If I remove the line for "opcache.file_cache_only=1", then memory_get_usage() remains constant.
If it doesn't happen the 1st time, then try running it a 2nd time.
Can you please check why the memory usage continues to grow in this scenario?
Thanks for your help.
test.php:
<?php
for ($i = 0; $i < 10000; $i++)
{
echo number_format(memory_get_usage())."\n";
require('test2.php');
}
test2.php:
<?php
return;
PHP Version
PHP 8.1.11
Operating System
AlmaLinux 8
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the supplied test.php and test2.php scripts with opcache.enable_cli=1 and opcache.file_cache_only=1, then compare memory_get_usage() with file_cache_only disabled. Investigate the PHP opcache file-cache path involved in repeated test2.php requirements; done means the reported growth is explained and the reproduction no longer shows increasing memory.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100