user616076
user616076

Reputation: 4001

didReceiveMemoryWarning not being called before memory crash

I'm loading a couple of large csv files when my app loads for the first time and this works fine on the simulator but when running on my phone it crashes about 30% through with the message 'Program received signal "0"' which implies a memory crash. However, when I put a breakpoint in the didReceiveMemoryWarning event it doesn't seem to be called.

Am I missing anything or will the program normally shut down without the event being called?

Upvotes: 0

Views: 707

Answers (2)

jlehr
jlehr

Reputation: 15617

If you're loading the file in a synchronous call on your app's main thread, that would prevent it from receiving other messages (such as memory warnings) before the synchronous call completes. Try making loading the CSV files an asynchronous task. (A good starting point would be reading up on NSOperation.) That will allow your app to receive memory warnings during the loading process.

Upvotes: 2

Khomsan
Khomsan

Reputation: 553

What's happen if you try loading small csv instead. If it work fine then your csv is too large and cause memory issue. If so you may have to read the csv file chunk by chunk and release the memory of the old one before reading the new one.

Upvotes: 0

Related Questions