• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Reading too many Files into Array returns Nil
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Reading too many Files into Array returns Nil


  • Subject: Re: Reading too many Files into Array returns Nil
  • From: John Stiles <email@hidden>
  • Date: Mon, 12 Sep 2005 23:07:28 -0700

Once you have more than a few hundred open file handles, the system starts to refuse to open more files.
Your options:
- close your files when you're done with them! Maybe you just need an autorelease pool around your file opening code.
- use setrlimit to raise the limit to the maximum open file limit (there appears to be no downside to this, so I don't know why it isn't the default)
In every non-trivial program I've worked on for OS X, I've always needed the setrlimit code eventually. There's always /something/ that ends up blowing the limit.


Oh, and for some reason the debugger turns off the resource limit. Not sure why that is, but it's really frustrating since it makes the problem more difficult to debug until you realize what's going on. :|


Mike Oldham wrote:

New cocoa Developer, and new to the list, so bear with me.

I'm reading files with NSFileHandle.
The number of files is never the same. When reading a few files, everything works fine.
When reading several hundred I get this Error.



2005-09-12 22:59:27.111 ArtiX[4388] An uncaught exception was raised 2005-09-12 22:59:27.111 ArtiX[4388] *** -[NSCFArray addObject:]: attempt to insert nil 2005-09-12 22:59:27.111 ArtiX[4388] *** Uncaught exception: <NSInvalidArgumentException> *** -[NSCFArray addObject:]: attempt to insert nil


Here is the read code.

LargeFile = [NSFileHandle fileHandleForReadingAtPath:fString];
tmpData  = [LargeFile readDataOfLength:4];
tmpStringName  = [LargeFile readDataOfLength:32];
tmpData  = [LargeFile readDataOfLength:4];
tmpTagName  = [LargeFile readDataOfLength:4];
[ProjStringName addObject:tmpStringName];
[ProjTagName addObject:tmpTagName];
[ProjTagPosition addObject:[NSNumber numberWithInt:-1]];
[ProjTagLength addObject:fString];

The weird thing is, when i run in debug mode it works fine.


Any ideas?


Mike _______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Reading too many Files into Array returns Nil
      • From: Alexander Repty <email@hidden>
References: 
 >Reading too many Files into Array returns Nil (From: Mike Oldham <email@hidden>)

  • Prev by Date: Re: Is there a trick to NSTableViews?
  • Next by Date: Re: Reading too many Files into Array returns Nil
  • Previous by thread: Reading too many Files into Array returns Nil
  • Next by thread: Re: Reading too many Files into Array returns Nil
  • Index(es):
    • Date
    • Thread