首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >核心绘图条形图图库在iOS 8中崩溃

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

Stack Overflow用户
提问于 2015-01-30 01:26:09
回答 1查看 211关注 0票数 0

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

代码语言:javascript
运行
复制
* 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,但找不到崩溃的原因

代码语言:javascript
运行
复制
- (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 files also enclosed

我的项目是带有新的Xcode6.1.1的ARC,但是我在GraphView的编译源代码中使用了-fno-objc-arc.我已经从Core Plot Bar Github下载了库

EN

回答 1

Stack Overflow用户

发布于 2015-01-31 00:52:42

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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28220882

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档