objective c - how to run the loop many times -
i apending string, running loop many times app crashed. it's show error message how mange error message malloc: * mmap(size=16777216) failed (error code=12) error: can't allocate region set breakpoint in malloc_error_break debug * terminating app due uncaught exception 'nsmallocexception', reason: 'out of memory. suggest restarting application. if have unsaved document, create backup copy in finder, try save.' , code ` nsmutablestring * str = [nsmutablestring stringwithcapacity:100000];
int i; for(i=0;i<1000000;i++){ [str appendstring:@"abcd"];
}`
without knowing details of actually doing, impossible say.
in general, when run out of memory, answer use less memory.
for operation involving massive chunk of data, need move operation buffers through disk. can done via number of means. 1 used depends on details of whatever trying do.
if appending text buffer, open file descriptor (or nsfilehandle
) , write instead.
Comments
Post a Comment