Recursive search on a linux system (1 thread) from root including subdirectories causes 8.4 GB Ram and counting
オープン
まだ誰も着手していません。
Bug
Status: Needs Triage
- 主要言語
- C
- スター
- 40.4k
- フォーク
- 8.2k
- 平均マージ
- 2日 13時間
- マージ済み PR(30日)
- 96
説明
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
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
提供されたCLIコマンド、PHP 8.4.12、およびDebian bookworm環境から開始し、その後、アプリケーションのDir::read呼び出しを追跡しながらメモリ増加を再現します。その挙動がPHPによるものかアプリケーションコードによるものかを切り分け、最小限の再現ケースとメモリの期待される挙動を文書化します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- debian, linux, php
- 領域
- cli, operating-systems
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 25/100