Reputation: 3
want to open a large text file and then search the content of it. I loaded the file with stringWithContentsOfFile into a NSString. Every thing works on a 30mb file. But I am concerned what happens if I load a 200mb file, which I want to do. Is the complete NSString in the memory? if so it wouldn't work on iPhone. is there a solution for such large files on the iPhone?
Upvotes: 0
Views: 780
Reputation: 10378
A good way to read a large file would be to buffer small chunks of it at a time.
Not sure of the exact API methods you could use to do this, but it is fairly standard practice for audio, video, etc to read a small amount of the file into memory, process this, and remove it from memory as you continue through the file.
Upvotes: 1
Reputation: 10393
Since the limit isn't documented the way to check would be actually profiling it on target. People may be able to give their limits here but that is totally relative. Also a good memory management scheme and design would help you avoid problems of running out of memory.
Upvotes: 0