繁体   English   中英

核心图条形图库在iOS 8中崩溃

[英]Core Plot Bar Graph Library crashing in iOS 8

我已经在项目中集成了CorePlot条形图库,但是由于内存泄漏,我的图崩溃了,我也启用了NSZombieEnabled,但是它崩溃了,如下所示。

* thread #1: tid = 0x38f7f, 0x0529a2e0 libsystem_kernel.dylib`vm_allocate + 18, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=2, address=0xbf78fff8)
    frame #0: 0x0529a2e0 libsystem_kernel.dylib`vm_allocate + 18
    frame #1: 0x00a7e57f libgmalloc.dylib`GMmalloc_zone_malloc_internal + 731
    frame #2: 0x00a7d3fc libgmalloc.dylib`GMmalloc_zone_malloc + 89
    frame #3: 0x00a7d26d libgmalloc.dylib`GMmalloc_zone_calloc + 100
    frame #4: 0x00a7cee4 libgmalloc.dylib`GMcalloc + 58
    frame #5: 0x042e3cc1 libobjc.A.dylib`class_createInstance + 68
    frame #6: 0x0460dbe1 CoreFoundation`__CFAllocateObject2 + 33
    frame #7: 0x0460dd08 CoreFoundation`+[__NSArrayI __new:::] + 40
    frame #8: 0x0460de4c CoreFoundation`-[__NSPlaceholderArray initWithObjects:count:] + 204
    frame #9: 0x01d855b3 QuartzCore`-[CALayerArray copyWithZone:] + 80
    frame #10: 0x042edb45 libobjc.A.dylib`-[NSObject copy] + 41
    frame #11: 0x02b16da1 UIKit`-[UIView(Hierarchy) _makeSubtreePerformSelector:withObject:withObject:copySublayers:] + 200
    frame #12: 0x02b16fe2 UIKit`__85-[UIView(Hierarchy) _makeSubtreePerformSelector:withObject:withObject:copySublayers:]_block_invoke + 162
    frame #13: 0x02b16eb9 UIKit`-[UIView(Hierarchy) _makeSubtreePerformSelector:withObject:withObject:copySublayers:] + 480
    frame #14: 0x02b16fe2 UIKit`__85-[UIView(Hierarchy) _makeSubtreePerformSelector:withObject:withObject:copySublayers:]_block_invoke + 162
    frame #15: 0x02b16eb9 UIKit`-[UIView(Hierarchy) _makeSubtreePerformSelector:withObject:withObject:copySublayers:] + 480
    frame #16: 0x02b16fe2 UIKit`__85-[UIView(Hierarchy) _makeSubtreePerformSelector:withObject:withObject:copySublayers:]_block_invoke + 162
    frame #17: 0x02b16eb9 UIKit`-[UIView(Hierarchy) 

我也附上了GraphView代码,并从代码中也删除了dealloc,但无法找出崩溃的原因

- (void)generateData:(NSArray *)customerArr  withVisitCounts:(NSArray *)visitCountsArr
{
    NSMutableDictionary *dataTemp = [[NSMutableDictionary alloc] init];

    //Array containing all the dates that will be displayed on the X axis
    dates = [NSArray arrayWithObjects:@"TestData", @"TestData", @"TestData",
             @"TestData", @"TestData", nil];

    //Dictionary containing the name of the two sets and their associated color
    //used for the demo
    sets = [NSDictionary dictionaryWithObjectsAndKeys:[UIColor blueColor], @"Plot 1", nil];

    //Generate random data for each set of data that will be displayed for each day
    //Numbers between 1 and 10
    for (NSString *date in dates) {
        NSMutableDictionary *dict = [NSMutableDictionary dictionary];
        for (NSString *set in sets) {
            NSNumber *num = [NSNumber numberWithInt:arc4random_uniform(10)+1];
            [dict setObject:num forKey:set];
        }
        [dataTemp setObject:dict forKey:date];
    }

    self.data =  [NSDictionary dictionaryWithDictionary:[dataTemp copy]];
    [dataTemp release];

    NSLog(@"%@", data);
}

随附的GraphView文件

我的项目是带有新xcode 6.1.1的ARC,但是我在GraphView的编译源中使用-fno-objc-arc,并且已经从Core Plot Bar Github下载了库

GraphView类中启用ARC。 这是一个简单的转换,它将修复几个明显的内存管理错误(也许还有其他一些不太明显的错误)。 该行[plot.dataSource retain]; 等同于[self retain]; ,因此视图将永远不会被释放。 另外, -generateData: withVisitCounts:[dataTemp copy]从未发布。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM