内存占用量增加,应用崩溃

时间:2019-02-06 05:06:08

标签: ios objective-c sqlite memory-management nsarray

嗨,在我的应用程序中,我有大约80000个事件的数据。每个事件都包含程序名称,时间,持续时间,评分,说明等数据。所有这些事件均在事件数组中,并且在将数据转换为模型对象后,它们存储在db中。

       if(eventInfoArray.count >= 20)
                    {

                    IVZEventModel * eventModel = [[IVZEventModel alloc]init];

                    eventModel.serviceId = [eventInfoArray[0] integerValue];
                    eventModel.channelNumber=[eventInfoArray[1] integerValue];
                    eventModel.description=eventInfoArray[2];

                    // End time
                    NSTimeInterval _endinterval=[eventInfoArray[3] doubleValue]*60;
                    NSDate *endDate = [NSDate dateWithTimeIntervalSince1970:_endinterval];
                    NSUInteger endTimeEpoch = round([endDate timeIntervalSince1970]);

                    eventModel.endTime=endTimeEpoch;
                    eventModel.identifier=[eventInfoArray[4] integerValue];
                    eventModel.imagePath=eventInfoArray[5];
                    eventModel.programTitle=eventInfoArray[6];

                    // Start time
                    NSTimeInterval _startinterval=[eventInfoArray[7] doubleValue]*60;
                    NSDate *srtDate = [NSDate dateWithTimeIntervalSince1970:_startinterval];
                    NSUInteger startTimeEpoch = round([srtDate timeIntervalSince1970]);

                    eventModel.startTime=startTimeEpoch;
                    eventModel.tvRating=eventInfoArray[8];
                    eventModel.genres=eventInfoArray[9];
                    eventModel.releaseYear=eventInfoArray[10];
                    eventModel.castInfo=eventInfoArray[11];


                    eventModel.showType=eventInfoArray[12];
                    eventModel.episodeTitle=eventInfoArray[13];
                    eventModel.sportsSubTitle=eventInfoArray[14];
                    eventModel.episodeSeasonNumber=eventInfoArray[15];
                    eventModel.episodeSeasonSequence=eventInfoArray[16];
                    eventModel.originAirDate=[eventInfoArray[17] integerValue];
                    eventModel.recordLanguage=eventInfoArray[18];
                    eventModel.movieType=eventInfoArray[19];

                    // Final array which have all services/channels list of information
                    [eventsArray addObject:eventModel];

                   eventModel=nil;

                   }

在将所有模型添加到eventsArray后,我将其存储在DB中。但是在循环以上代码时,内存的存储速度非常快(在iphone 6中,1GB 700mb占用了该进程),这会导致应用崩溃。谁能让我知道解决这个问题的方法。

0 个答案:

没有答案