Go Back   The macosxhints Forums > Working with OS X > OS X Developer



Reply
 
Thread Tools Rate Thread Display Modes
Old 08-31-2007, 12:05 AM   #1
sakiel
Prospect
 
Join Date: Jul 2007
Posts: 15
It is a very stange problem, about Creating and Opening Files

I made a test, i created and opened many files continuously, but not closed them. it always failed to create the new file at about the 250th file, not more than 256 files. i tried the functions, include fopen, HCreate, HopenDF, etc. All like this. I did the same work at Windows XP, it was successfully. This is very strange, do you think it is about Mac OS X system?
sakiel is offline   Reply With Quote
Old 08-31-2007, 01:19 AM   #2
hayne
Site Admin
 
Join Date: Jan 2002
Location: Montreal
Posts: 31,956
Every operating system has a limit on the number of files that a process is allowed to have open. The exact number varies between operating systems and is usually configurable by the system administrator.

I.e. what you experienced doesn't seem strange at all - it is quite normal. It is usually a programming error to be opening so many files without closing them.
__________________
hayne.net/macosx.html
hayne is offline   Reply With Quote
Old 08-31-2007, 01:42 AM   #3
tw
Hall of Famer
 
Join Date: Apr 2007
Posts: 4,262
just as an added point, I suspect most systems will use a binary limit (64, 128, 256, 512, 1024...) on the number of open files, just because - hey - it's a computer. the question you're having here is probably a credit to macs. for the most part, computers have no conception of an 'appropriate' limit to the number of open files that should be allowed. old systems would simply allow you to keep opening file after file after file until something overloads and the system crashes. apparently macs have put a limit on it. I'm guessing the limit can be changed programmatically, but be glad it's there...
tw is offline   Reply With Quote
Old 08-31-2007, 02:32 AM   #4
sakiel
Prospect
 
Join Date: Jul 2007
Posts: 15
yeah,u r right. i ran "unlimit -n", it shows 256.How can i change this limit.
sakiel is offline   Reply With Quote
Old 08-31-2007, 02:47 AM   #5
hayne
Site Admin
 
Join Date: Jan 2002
Location: Montreal
Posts: 31,956
Quote:
Originally Posted by sakiel
yeah,u r right. i ran "unlimit -n", it shows 256.How can i change this limit.

I'm not sure - but why do you need to change it?
What are you trying to do? I.e. what is your higher-level goal?
__________________
hayne.net/macosx.html
hayne is offline   Reply With Quote
Old 08-31-2007, 04:01 AM   #6
sakiel
Prospect
 
Join Date: Jul 2007
Posts: 15
I created so many files as temporary files to store some image info. Not closing them is for the fast access in the future.So, it is why i need to do this.
sakiel is offline   Reply With Quote
Old 08-31-2007, 07:43 AM   #7
BadgerUMD
Triple-A Player
 
Join Date: Mar 2006
Posts: 110
I know it's not really an answer to your question, but ...

I'm not 100% sure why you would want to save large numbers of temporary image files but not close -- it may be faster to only keep open those files you need, as you use a lesser amount of system resources. And if you want really fast access, why write them to a file at all? Just keep them resident in memory.
BadgerUMD is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT -5. The time now is 08:23 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.