ID: 35997 Updated by: [EMAIL PROTECTED] Reported By: rquadling at gmail dot com -Status: Assigned +Status: Bogus Bug Type: SPL related -Operating System: Windows XP SP2 +Operating System: * -PHP Version: 5.1.2 +PHP Version: 5.* Assigned To: helly New Comment:
Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php First you must explicitly destruct objects holding resources to free the resources. Second instead of "'Modified' => filemtime($s_FileName), " you should be using "$o_File->getATime()" or getMTime() or getCTime(). Sidenote there is no reason to use \ instead / unless you were generating batch files. If you are using \ because of any PHP function then you should open a bug report for that. Previous Comments: ------------------------------------------------------------------------ [2006-01-13 17:48:52] [EMAIL PROTECTED] Assigned to the maintainer. ------------------------------------------------------------------------ [2006-01-13 16:52:10] rquadling at gmail dot com Description: ------------ Using a FilterIterator on a DirectoryIterator does not close the handle of the directory being iterated. If I do not use a FilterIterator and process the files manually from the DirectoryIterator, the handle is released. To see this in action ... Place a bunch of CSV files in the C:\TEMP directory and create a C:\TEMP\JUNK directory. The code below will loop until it has 1000 CSV files. Using System Internals Process Explorer you can see that the number of handles used by php.exe goes up and up and up. I have several programs which loop over a directory repeatedly. I have stopped using the FilterIterator and use just a DirectoryIterator and then manually filter the filenames. Reproduce code: --------------- <?php class FileTypeList extends FilterIterator { protected $s_Type; function __construct($s_Path, $s_Type) { $this->s_Type = $s_Type; parent::__construct(new DirectoryIterator($s_Path)); } function accept() { $b_Result = (strcasecmp($this->s_Type, pathinfo($this->current(), PATHINFO_EXTENSION)) !== 0); return $b_Result; } } $am_Files = array(); while(count($am_Files) < 1000) { echo "Looking\n"; foreach(new FileTypeList('C:\\TEMP', 'CSV') as $o_FILE) { if ($o_FILE->isFile()) { $s_FileName = str_replace('/', DIRECTORY_SEPARATOR, $o_FILE->getPathname()); // Directory separator required for windows filenames. $am_Files[] = array ( 'Modified' => filemtime($s_FileName), 'Name' => $s_FileName, ); rename($s_FileName, 'C:\\TEMP\\JUNK\\' . basename($s_FileName)); echo "Found $s_FileName\n"; } } } print_r($am_Files); ?> Expected result: ---------------- File handles to open and close as required. Actual result: -------------- File handles are opened and stay open. System resources get used up. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=35997&edit=1
