App crash when trying to load a large amount off data into my app

前端 未结 2 1557
無奈伤痛
無奈伤痛 2021-01-20 04:08

I am trying to load a JSON of 40 000+ records into my Realm Database. Here is my function

AFJSONRequestOperation *operation = [[AFJ         


        
2条回答
  •  再見小時候
    2021-01-20 04:58

    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.

提交回复
热议问题