极高的匿名虚拟机和应用程序崩溃

时间:2014-06-17 09:53:26

标签: ios objective-c ipad memory-management memory-leaks

我有一个很大的问题,我无法处理。我的应用程序使用iBeacons来显示视图并加载存储在CoreData中的一些图片,但是,这不是真正的问题。 我将一些pics从解析加载到核心数据,然后从核心数据中检索以显示。

当我从一个视图更改为另一个视图时,我认为它可以增加,但是当我退出视图时,可以释放内存吗?我不知道它我解释得很好,但我希望你能理解我并尽可能多地帮助我。

我在iPad上使用Xcode 5.1.1和iOS 7.1

现在我正在使用乐器试着看看发生了什么,这就是我得到的。

分配: Look at Anonymous VM Memory Leaks Anonymous VM list

我认为我做错了,加载这样的图片,不知道问题是什么:_(

self.itemsSection1 = [[NSMutableArray alloc] init];
    self.generalImages1 = [[NSMutableArray alloc] init];
    [self fillArraysWithItems:self.itemsSection1 section:@"1"];
    [self fillArraysWithGeneralImages:self.generalImages1 section:@"1"];
    self.itemImages = [NSArray
                       arrayWithObjects:[UIImage imageWithData:self.itemsSection1[0][@"image"]],
                       [UIImage imageWithData:self.itemsSection1[1][@"image"]],
                       [UIImage imageWithData:self.itemsSection1[2][@"image"]],
                       [UIImage imageWithData:self.itemsSection1[3][@"image"]],
                       [UIImage imageWithData:self.itemsSection1[4][@"image"]], nil];
    for (int i=0; i<self.generalImages1.count; i++) {
        [self.itemSliderImages addObject:[UIImage imageWithData:self.generalImages1[i][@"image"]]];
    }
    generalImage.image = [UIImage imageWithData:self.generalImages1[0][@"image"]];
    self.img_elements.image = generalImage.image;
    self.navBar_title.title = @"Catering";

FillArraysWithItems:

    -(void)fillArraysWithItems: (NSMutableArray*)item section:(NSString*)section{

    AppDelegate *delegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
    NSEntityDescription *entity = [NSEntityDescription entityForName:@"Item" inManagedObjectContext:delegate.managedObjectContext];

    NSFetchRequest *fetchedRequest = [[NSFetchRequest alloc]init];
    [fetchedRequest setEntity:entity];

    self.allItemInfo = [[delegate.managedObjectContext executeFetchRequest:fetchedRequest error:nil] mutableCopy];
    NSLog(@"\n\nAllItems:%@\n", self.allItemInfo);
    for (NSManagedObjectContext *obj in self.allItemInfo) {
        //Save data from CoreData to arrays
        NSLog(@"\n\nObject:\n%@", obj);
        NSString *micro = @"micro_off.png";
        NSString *oven = @"oven_off.png";
        NSString *recycle = @"recycle_off.png";
        NSString *biodeg = @"biodeg_off.png";
        NSString *liquid = @"liquid_off.png";
        NSString *perso = @"perso_off.png";
        NSLog(@"\n\nName:%@\nRef:%@\nPricePack:%@\nUnitPrice:%@\nunitsPack:%@",[obj valueForKey:@"name"], [obj valueForKey:@"reference"],[obj valueForKey:@"pricePack"], [obj valueForKey:@"priceUnity"], [obj valueForKey:@"unitsPack"]);
        NSLog(@"\n\nMicro:%@\nOven:%@\nRecycle:%@\nBiodeg:%@\nLiquid:%@\nPerso:%@\n", [obj valueForKey:@"micro"], [obj valueForKey:@"oven"], [obj valueForKey:@"recycle"], [obj valueForKey:@"bio"], [obj valueForKey:@"liquid"], [obj valueForKey:@"perso"]);

        if ([[obj valueForKey:@"section"] isEqual:section]) {
            if ([[obj valueForKey:@"micro"]  isEqual: @1]) {
                micro = @"micro_on.png";
            }
            if ([[obj valueForKey:@"oven"] isEqual: @1]) {
                oven = @"oven_on.png";
            }
            if ([[obj valueForKey:@"recycle"] isEqual: @1]) {
                recycle = @"recycle_on.png";
            }
            if ([[obj valueForKey:@"bio"] isEqual: @1]) {
                biodeg = @"biodeg_on.png";
            }
            if ([[obj valueForKey:@"liquid"] isEqual: @1]) {
                liquid = @"liquid_on.png";
            }
            if ([[obj valueForKey:@"perso"] isEqual: @1]) {
                perso = @"perso_on.png";
            }
            [item addObject:@{@"name": [obj valueForKey:@"name"],
                              @"pricePack": [obj valueForKey:@"pricePack"],
                              @"priceUnity": [obj valueForKey:@"priceUnity"],
                              @"reference": [obj valueForKey:@"reference"],
                              @"unitsPack": [obj valueForKey:@"unitsPack"],
                              @"micro": [UIImage imageWithContentsOfFile:micro],
                              @"oven": [UIImage imageWithContentsOfFile:oven],
                              @"recycle": [UIImage imageWithContentsOfFile:recycle],
                              @"bio": [UIImage imageWithContentsOfFile:biodeg],
                              @"liquid": [UIImage imageWithContentsOfFile:liquid],
                              @"perso": [UIImage imageWithContentsOfFile:perso],
                              @"image": [UIImage imageWithContentsOfFile:[obj valueForKey:@"image"]]}];
        }
    }
    NSError *error;
    BOOL isFetched = [delegate.managedObjectContext save:&error];
    NSLog(@"Arrays successfully filled: %d", isFetched);
}

这是[item addObject ...

时出现的错误
    2014-06-18 09:25:50.176 IBKS[383:60b] -[_PFExternalReferenceData stringByDeletingPathExtension]: unrecognized selector sent to instance 0x14d51f50
2014-06-18 09:25:50.178 IBKS[383:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[_PFExternalReferenceData stringByDeletingPathExtension]: unrecognized selector sent to instance 0x14d51f50'
*** First throw call stack:
(0x2f8f1f0b 0x3a3cece7 0x2f8f5837 0x2f8f4137 0x2f843098 0x3213d13f 0x3213d107 0x3213d0dd 0x3213d0ab 0x322487e5 0xd2fe5 0xa76a5 0x32125a53 0x32125811 0x321cf043 0x3220bc4b 0x3220a57d 0x322095f9 0xa01cb 0x9debf 0x2fdb6e91 0x2fdb1aeb 0x2fdab081 0x2f8bd01d 0x2f8bc397 0x2f8bb001 0x2f825769 0x2f82554b 0x3475f6d3 0x32184891 0x9a5ed 0x3a8ccab7)
libc++abi.dylib: terminating with uncaught exception of type NSException

希望任何人都可以提供帮助。

由于

0 个答案:

没有答案