php / php/php-src

Recursive search on a linux system (1 thread) from root including subdirectories causes 8.4 GB Ram and counting

Aperta
#20,459 4 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

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

Descrizione

Description

The following code:

<?php
/**
     * @throws DirectoryCreateException
     * @throws Exception
     */
    public function search($flags, $options): void
    {
        $object = $this->object();
        $data = new Data($object->data());
        if(!property_exists($options, 'name')){
            throw new Exception('Option -name not set');
        }
        if(!property_exists($options, 'directory')){
            throw new Exception('Option -directory not set');
        }
        $dir = new Dir();
        $list = $dir->read($options->directory, true);
        foreach($list as $file){
            if($file->name === $options->name){
                breakpoint('match');
            }
        }
        breakpoint($list);
    }

Resulted in this output:

15625 root      20   0 9139760   8.5g   2304 R  99.7  55.0  15:11.97 php
15625 root      20   0   13.3g  13.0g   2304 R 100.0  83.9  24:48.36 php

But I expected this output instead:

15625 root      20   0 9139760   1.5g   2304 R  99.7  3.0  15:11.97 php

What i meant is this:

I keep a list of all files on the system and searches for a match.
I can create a search from root directory and go 1 subdirectory at a time but my opinion is that searching on a root device should work like a charm without complicating stuff too much...

PHP Version
PHP 8.4.12 (cli) (built: Sep  7 2025 14:06:59) (NTS)
Copyright (c) The PHP Group
Built by Debian
Zend Engine v4.4.12, Copyright (c) Zend Technologies
    with Zend OPcache v8.4.12, Copyright (c), by Zend Technologies
Operating System

Debian bookworm
CLI:
app raxon/basic file search -directory=/ -name=Snow.js

No response

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 con il comando CLI fornito, PHP 8.4.12 e l’ambiente Debian bookworm, quindi riproduci la crescita della memoria mentre tracci la chiamata a Dir::read dell’applicazione. Isola se il comportamento proviene da PHP o dal codice dell’applicazione e documenta un caso minimo riproducibile e il comportamento atteso della memoria.

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

Valutazione

Stack tecnologico
debian, linux, php
Ambito
cli, operating-systems
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.