php / php/php-src

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

Aperta
#9,812 4 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Bug Extension: opcache Status: Verified
Lingua principale
C
Stelle
40.4k
Fork
8.2k
Merge medio
2g 13h
PR unite (30g)
96

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia eseguendo gli script forniti test.php e test2.php con opcache.enable_cli=1 e opcache.file_cache_only=1, quindi confronta memory_get_usage() con file_cache_only disabilitato. Analizza il percorso della cache dei file di PHP opcache coinvolto nelle richieste ripetute di test2.php; il lavoro è completato quando la crescita segnalata è spiegata e la riproduzione non mostra più un aumento della memoria.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
php
Ambito
performance
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.