I am trying to load a JSON
of 40 000+ records into my Realm Database
. Here is my function
AFJSONRequestOperation *operation = [[AFJ
Wrap loop's body in @autoreleasepool
Also copying the same JSON twice seems redundant.
This problem is unrelated to Realm.
I am trying to load a JSON of 40 000+ records
There's your problem. AFJSONRequestOperation
will attempt to deserialize the JSON in memory and your app will no longer have any available memory, and will get terminated.
Also I noticed that it does not crashed on simulator...
This is because the simulator has access to much more memory than an iOS device.
You should find ways to reduce the size of your network requests, either by requesting less data at a time or using a less wasteful response format than JSON strings.