Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
General
GeneralPortable MacsHardwareNetworking
Applications
Mac ApplicationsEudoraFirefox / MozillaInternet ExplorerOutlook ExpressMS OfficeEntourageExcelPowerPointWordVirtual PCMedia PlayerOther MS Products
Programming
Mac ProgrammingCodeWarriorPerl
Country Specific
Australian Mac GroupUK Mac Group

Mac Forum / Programming / Mac Programming / May 2007



Tip: Looking for answers? Try searching our database.

stringWithContentsOfFile question

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jim - 24 May 2007 13:10 GMT
Using stringWithContentsOfFile I can load an NSString with the contents
of a file (obviously).

What are the practical limits with regard to the size of file that could
be handled?

Jim
Signature

Find me at http://www.ursaMinorBeta.co.uk

My lucky star is probably Eta Carinae.

Gregory Weston - 24 May 2007 15:06 GMT
> Using stringWithContentsOfFile I can load an NSString with the contents
> of a file (obviously).
[quoted text clipped - 3 lines]
>
> Jim

The NSString documentation references this from NSString.h

NSMaximumStringLength

A constant to define the maximum number of characters in an NSString
object.

#define NSMaximumStringLength (INT_MAX-1)

The practical limits I would expect are dependent quite a bit on the
specific machine and the amount of space available in the process's
address space; I wouldn't necessarily expect great performance handling
a 3GB string on a machine with 512MB of RAM, for example.
Jim - 24 May 2007 15:16 GMT
>> Using stringWithContentsOfFile I can load an NSString with the contents
>> of a file (obviously).
[quoted text clipped - 17 lines]
> address space; I wouldn't necessarily expect great performance handling
> a 3GB string on a machine with 512MB of RAM, for example.

Overall performance would be a major factor for me, and I expect the
largest file I'd be handling this way would be in the 1GB region, but
mostly in the 250MB range.

Thanks for the info.

Jim
Signature

Find me at http://www.ursaMinorBeta.co.uk

My lucky star is probably Eta Carinae.

Tom Harrington - 24 May 2007 18:27 GMT
> Overall performance would be a major factor for me, and I expect the
> largest file I'd be handling this way would be in the 1GB region, but
> mostly in the 250MB range.

Depending on what you're doing with these files, you might want to
consider loading them as memory-mapped files.  NSData objects can be
initialized this way, and you should be able to get an NSString from
there.

Signature

Tom "Tom" Harrington
MondoMouse makes your mouse mightier
See http://www.atomicbird.com/mondomouse/

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.