Maximum number of open files

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Extremest
Forum Commoner
Posts: 84
Joined: Mon Aug 29, 2005 12:39 pm

Maximum number of open files

Post 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.
Grim...
DevNet Resident
Posts: 1445
Joined: Tue May 18, 2004 5:32 am
Location: London, UK

Post by Grim... »

4096 files in PHP?

As Obi-Wan would say: "This is not the programming language you are looking for."
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Post by Jenk »

Why would you need to open 4096 files concurrently?
Extremest
Forum Commoner
Posts: 84
Joined: Mon Aug 29, 2005 12:39 pm

Post 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.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post 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..
sheila
Forum Commoner
Posts: 98
Joined: Mon Sep 05, 2005 9:52 pm
Location: Texas

Re: Maximum number of open files

Post 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?
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Re: Maximum number of open files

Post by hawleyjr »

sheila wrote: Is there a work around?
Yes, use a database.
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Post by Jenk »

Use Java.
Extremest
Forum Commoner
Posts: 84
Joined: Mon Aug 29, 2005 12:39 pm

Post by Extremest »

Database is what it will go into once the duplicates are removed. I don't know java yet.
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Post 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)
Post Reply