Page 1 of 1
Maximum number of open files
Posted: Wed Dec 07, 2005 9:56 pm
by Extremest
I believe in windows php is only allowed to have 256 files open at one time. I tried to have a script that would use 4096 files. so I had it open each file and write what was needed then close it then open the next one. Problem when it was done the page did not finish. And after telling apache to restart it couldn't had to restart the whole system to get everything back up. Was not sure if maybe I am doing it right or not.
Posted: Thu Dec 08, 2005 6:28 am
by Grim...
4096 files in PHP?
As Obi-Wan would say: "This is not the programming language you are looking for."
Posted: Thu Dec 08, 2005 6:35 am
by Jenk
Why would you need to open 4096 files concurrently?
Posted: Thu Dec 08, 2005 3:49 pm
by Extremest
well what it I need to do is put different things in each file depending on the first 3 letters. There is 4096 total. I was just going to have it open the one that it needs at write time then close after the write and move on to the next one.
Posted: Thu Dec 08, 2005 4:08 pm
by John Cartwright
Extremest wrote:well what it I need to do is put different things in each file depending on the first 3 letters. There is 4096 total. I was just going to have it open the one that it needs at write time then close after the write and move on to the next one.
That makes a lot more sense than loading 4096 files into memory..
Re: Maximum number of open files
Posted: Thu Dec 08, 2005 5:06 pm
by sheila
And that is what he originally said:
Extremest wrote:I had it open each file and write what was needed then close it then open the next one.
but it didn't work out
Problem when it was done the page did not finish. And after telling apache to restart it couldn't had to restart the whole system to get everything back up. Was not sure if maybe I am doing it right or not.
So why didn't it work? Is the problem Windows, PHP, Apache or his code? Is there a work around?
Re: Maximum number of open files
Posted: Thu Dec 08, 2005 6:35 pm
by hawleyjr
sheila wrote: Is there a work around?
Yes, use a database.
Posted: Thu Dec 08, 2005 8:57 pm
by Jenk
Use Java.
Posted: Thu Dec 08, 2005 9:13 pm
by Extremest
Database is what it will go into once the duplicates are removed. I don't know java yet.
Posted: Thu Dec 08, 2005 11:12 pm
by josh
Do you have a memory limit or max execution time set in your php.ini?
Try calling ob_implicit_flush() and outputting a success message every file, so you can track down exactly which file it is failing on.
Also is there something here that you're not mentioning, are any of the files ridiculously large / using strange character encoding for the filenames etc?
My guess for PHP to cause Apache to lock up like that you ran out of memory, can we take a look at your code just to ensure there is no infinite ninja-loops and that sort of thing? (no intention of offending you by questioning your ability to spot errors this blatant, but by looking at your code someone might see something that sticks out)