php / php/php-src

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

Offen
#20,459 4 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bug Status: Needs Triage
Vorherrschende Sprache
C
Sterne
40.4k
Forks
8.2k
Ø Merge
2 T. 13 Std.
Gemergte PRs (30 T.)
96

Beschreibung

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

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne mit dem bereitgestellten CLI-Befehl, PHP 8.4.12 und der Debian-bookworm-Umgebung und reproduziere dann das Speicherwachstum, während du den Aufruf von Dir::read in der Anwendung nachverfolgst. Isoliere, ob das Verhalten von PHP oder dem Anwendungscode verursacht wird, und dokumentiere einen minimal reproduzierbaren Fall sowie das erwartete Speicherverhalten.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
debian, linux, php
Bereich
cli, operating-systems
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Muss geklärt werden
Anfängerfreundlichkeit
25/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.