Objective c 此CoreData(目标C)代码段内存不足

Objective c 此CoreData(目标C)代码段内存不足,objective-c,Objective C,我编写此方法是为了测试CoreData备份存储。在运行测试方法时, 我的内存快用完了。我在内部循环中有100个元素和10个元素 外部循环中的记录。我正在iPad(实际设备)上测试 -(void)上传测试hubdata:(NSInteger)hubs-entriesPerHub:(NSInteger)元素 { CoreDataWrapper*cdw=[CoreDataWrapper getInstance:@”/Documents/journaldata0.sqlite]; [自动加载测试图像];

我编写此方法是为了测试CoreData备份存储。在运行测试方法时, 我的内存快用完了。我在内部循环中有100个元素和10个元素 外部循环中的记录。我正在iPad(实际设备)上测试

-(void)上传测试hubdata:(NSInteger)hubs-entriesPerHub:(NSInteger)元素
{
CoreDataWrapper*cdw=[CoreDataWrapper getInstance:@”/Documents/journaldata0.sqlite];
[自动加载测试图像];
对于(int i=0;i
乍一看,您似乎正在创建大约1000个自动删除的核心数据对象,以及许多自动删除的NSNumbers和NSDate对象。如果你有内存问题,你可能想考虑在你的内部for循环中添加一个nSAutoReleSeCype。谢谢你的建议。我已经这么做了!我收到以下错误消息。***-[NSAutoreleasePool drain]:此池已被排空,……请在外部循环之前尝试alloc/init,然后在退出内部循环后排空并alloc/init另一个实例。
-(void) uploadTestHubData: (NSInteger) hubs entriesPerHub: (NSInteger) elems
{
    CoreDataWrapper *cdw = [CoreDataWrapper getInstance:@"/Documents/journaldata0.sqlite"];
[self loadTestImages];

for (int i = 0; i < hubs; i++) {
    NSLog(@"Uploading hub - %d", i);

    Hub *newhub = [NSEntityDescription insertNewObjectForEntityForName:@"Hub" inManagedObjectContext:cdw.context];
    newhub.Title = @"Changed ... Hub Title";
    newhub.Last_Update = [NSDate date];
    newhub.Create_Date = [NSDate date];
    newhub.Type = [NSNumber numberWithInt:0];
    newhub.Description = @"This is a test hub. I am just testing the hub structure.";

    for (int j = 0; j < elems; j++) {
        HubBasicElement *helem = [NSEntityDescription insertNewObjectForEntityForName:@"HubBasicElement" inManagedObjectContext:cdw.context];
        helem.CoverArt = UIImagePNGRepresentation([self getRandomImage]);
        helem.Create_Date = [NSDate date];
        helem.Title = @"Title of Clipped Page";
        helem.ElementType = [NSNumber numberWithInt:0];
        helem.Source_URL = @"Some web URL";
        [newhub addChildrenObject:helem];
        [cdw commitCoreData];
    }
}       
NSLog(@"Finished uploading the test data ....");
}