php / php/php-src

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

オープン
#9,812 コメント 4 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

Bug Extension: opcache Status: Verified
主要言語
C
スター
40.4k
フォーク
8.2k
平均マージ
2日 13時間
マージ済み PR(30日)
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. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず、提供されたスクリプト test.php と test2.php を opcache.enable_cli=1 および opcache.file_cache_only=1 で実行し、次に file_cache_only を無効にした場合の memory_get_usage() と比較します。test2.php の繰り返しの require に関係する PHP opcache のファイルキャッシュパスを調査します。報告された増加が説明され、再現でメモリの増加が見られなくなれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
php
領域
performance
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。