[php-src] Issue #20459: Recursive search on a linux system (1 thread) from root including subdirectories causes 8.4 GB Ram and counting

From: Date: Wed, 12 Nov 2025 06:13:05 +0000
Subject: [php-src] Issue #20459: Recursive search on a linux system (1 thread) from root including subdirectories causes 8.4 GB Ram and counting
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-251208@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/20459 Author: remco-pc ### Description The following code: ```php <?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 ``` 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 ```plain 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 _No response_

« previous php.bugs (#251208) next »