Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/42.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 核心数据关系内存泄漏_Iphone_Core Data_Memory Leaks_Relationship - Fatal编程技术网

Iphone 核心数据关系内存泄漏

Iphone 核心数据关系内存泄漏,iphone,core-data,memory-leaks,relationship,Iphone,Core Data,Memory Leaks,Relationship,在访问关系中的实体时,我(对我来说)有一个奇怪的内存泄漏 系列和瓷砖之间的关系是相反的 // set up the fetch request NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]; NSEntityDescription *entity = [NSEntityDescription entityForName:@"Series" inManagedObjectContext:managedObjectConte

在访问关系中的实体时,我(对我来说)有一个奇怪的内存泄漏

系列和瓷砖之间的关系是相反的

// set up the fetch request
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Series" inManagedObjectContext:managedObjectContext];
[fetchRequest setEntity:entity];

// grab all of the series in the core data store
NSError *error = nil;
availableSeries = [[NSArray alloc] initWithArray:[managedObjectContext executeFetchRequest:fetchRequest error:&error]];
[fetchRequest release];

// grab one of the series
Series *currentSeries = [availableSeries objectAtIndex:1];
// load all of the tiles attached to the series through the relationship    
NSArray *myTiles = [currentSeries.tile allObjects];  // 16 byte leak here!
Instruments报告最后一行有一个由NSPlaceHolderString引起的16字节泄漏

堆栈跟踪:

 2 UIKit UIApplicationMain
 3 UIKit -[UIApplication _run]
 4 CoreFoundation CFRunLoopRunInMode
 5 CoreFoundation CFRunLoopRunSpecific
 6 GraphicsServices PurpleEventCallback
 7 UIKit _UIApplicationHandleEvent
 8 UIKit -[UIApplication sendEvent:]
 9 UIKit -[UIApplication handleEvent:withNewEvent:]
10 UIKit -[UIApplication _runWithURL:sourceBundleID:]
11 UIKit -[UIApplication _performInitializationWithURL:sourceBundleID:]
12 Memory -[AppDelegate_Phone application:didFinishLaunchingWithOptions:] /Users/cfish/svnrepo/Memory/src/Memory/iPhone/AppDelegate_Phone.m:49
13 UIKit -[UIViewController view]
14 Memory -[HomeScreenController_Phone viewDidLoad] /Users/cfish/svnrepo/Memory/src/Memory/iPhone/HomeScreenController_Phone.m:58
15 CoreData -[_NSFaultingMutableSet allObjects]
16 CoreData -[_NSFaultingMutableSet willRead]
17 CoreData -[NSFaultHandler retainedFulfillAggregateFaultForObject:andRelationship:withContext:]
18 CoreData -[NSSQLCore retainedRelationshipDataWithSourceID:forRelationship:withContext:]
19 CoreData -[NSSQLCore newFetchedPKsForSourceID:andRelationship:]
20 CoreData -[NSSQLCore rawSQLTextForToManyFaultStatement:stripBindVariables:swapEKPK:]
21 Foundation +[NSString stringWithFormat:]
22 Foundation -[NSPlaceholderString initWithFormat:locale:arguments:]
23 CoreFoundation _CFStringCreateWithFormatAndArgumentsAux
24 CoreFoundation _CFStringAppendFormatAndArgumentsAux
25 Foundation _NSDescriptionWithLocaleFunc
26 CoreFoundation -[NSObject respondsToSelector:]
27 libobjc.A.dylib class_respondsToSelector
28 libobjc.A.dylib lookUpMethod
29 libobjc.A.dylib _cache_addForwardEntry
30 libobjc.A.dylib _malloc_internal
我想我遗漏了一些明显的东西,但我不太明白是什么

谢谢你的帮助

更新:我已经将有问题的代码块复制到ApplicationIDFinishLaunching的第一部分,但它仍然泄漏。我的模型有问题吗


您是否发布可用性系列?除此之外,我什么也没看到

您是否发布可用性系列?除此之外,我什么也没看到

> P> NSPlaceHolder是由基础库使用的“单点”,在诸如:

等结构中推迟NSRSITE内存的分配。
[[NSString alloc] initWithString:@"only know the size of this string in the init, not the alloc"];
如果你只漏过一次,那就不是真的漏了

  • 我说“singleton”和“one”,但可以有多个NSPlaceHolderString—如果使用allocWithZone,则每个NSZone一个

NSPlaceHolder是由基础库使用的“单点”,在诸如

的构造中推迟NSRSITE内存的分配。
[[NSString alloc] initWithString:@"only know the size of this string in the init, not the alloc"];
如果你只漏过一次,那就不是真的漏了

  • 我说“singleton”和“one”,但可以有多个NSPlaceHolderString—如果使用allocWithZone,则每个NSZone一个

是的,稍后会发布。莫名其妙!是的,稍后会发布。莫名其妙!有趣!我仍然没有看到我所做的有什么可怕的错误,所以我现在就用这个。非常感谢你的帮助!有趣!我仍然没有看到我所做的有什么可怕的错误,所以我现在就用这个。非常感谢你的帮助!