I was reading a really large file into memory on the main thread (not just the simple dataWithContentsOfFile:
method, I was also doing some data manipulation), and my app crashed. After I moved this process to a background thread, the app doesn't crash anymore. The only thing that happens is that the NSData
I get is nil
.
Is it possible that only my background thread is interrupted without affecting the main thread, or am I missing something? Also, can I count on this behaviour and just display an error message when the NSData
is nil
, without the app to crash? Thank you in advance.
Edit:
The log I get is:
malloc: * mmap(size=629800960) failed (error code=12) error: can't allocate region ** set a breakpoint in malloc_error_break to debug
The file I was using is about 250 MB large.
I know why it crashed on the main thread. My question is, why didn't it crash on a secondary thread?