0

プロジェクトに 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からライブラリをダウンロードしています。

4

1 に答える 1

0

GraphViewクラスで ARC を有効にします。これは簡単な変換であり、いくつかの明らかなメモリ管理エラー (およびおそらくその他のあまり目立たないエラー) を修正します。この行[plot.dataSource retain];は と同等[self retain];であるため、ビューの割り当てが解除されることはありません。また、[dataTemp copy]イン-generateData: withVisitCounts:は決してリリースされません。

于 2015-01-30T16:52:41.567 に答える