php / php/php-src

memory usage increasing when using opcache.enable_cli and opcache.file_cache_only

未关闭
#9,812 4 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

Bug Extension: opcache Status: Verified
主要语言
C
星标
40.4k
派生
8.2k
平均合并
2 天 13 小时
30 天内合并 PR
96

描述

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

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先使用 opcache.enable_cli=1 和 opcache.file_cache_only=1 运行提供的 test.php 和 test2.php 脚本,然后将 memory_get_usage() 与禁用 file_cache_only 时的结果进行比较。调查重复 require test2.php 时涉及的 PHP opcache 文件缓存路径;当报告的增长得到解释且复现不再显示内存持续增长时,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
php
领域
performance
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。