我已经在我的项目中集成了 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);
}
我的项目是带有新 xcode 6.1.1 的 ARC,但我在 GraphView 的编译源中使用 -fno-objc-arc,并且我从Core Plot Bar Github下载了库