Skip to content

Commit ae1e18c

Browse files
committed
• Improved debugging code in SSYDeallocDetector.
• Fixed memory leak introduced in recent commit of SSYMOCManager (forgot to run static analyzer!)
1 parent 195e840 commit ae1e18c

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

SSYDeallocDetector.m

+13-4
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,19 @@
33

44
@implementation SSYDeallocDetector
55

6-
#if 0
7-
#warning Logging R&R of Dealloc Detector
6+
#if 11
7+
#warning Logging retains, releases and deallocs of Dealloc Detector
8+
#define LOG_RETAINS_RELEASES_AND_DEALLOCS 1
9+
#endif
10+
11+
#if LOG_RETAINS_RELEASES_AND_DEALLOCS
812
- (id)retain {
9-
NSLog(@"75133: Retained SSYDeallocDetector %p", self) ;
13+
NSLog(@"75133: Retained SSYDeallocDetector %p", (__bridge void*)self) ;
1014
return [super retain] ;
1115
}
1216

1317
- (oneway void)release {
14-
NSLog(@"75143: Released SSYDeallocDetector %p", self) ;
18+
NSLog(@"75143: Released SSYDeallocDetector %p", (__bridge void*)self) ;
1519
[super release] ;
1620
}
1721
#endif
@@ -20,9 +24,14 @@ - (void)dealloc {
2024
[_invocation invoke] ;
2125

2226
[_invocation release] ;
27+
#if LOG_RETAINS_RELEASES_AND_DEALLOCS
28+
NSLog(@"75153 Deallocced %p", (__bridge void*)self) ;
29+
#else
2330
if (_logMsg) {
2431
NSLog(@"Deallocced %p %@", (__bridge void*)self, _logMsg) ;
2532
}
33+
#endif
34+
2635
[_logMsg release] ;
2736

2837
[super dealloc] ;

SSYMOCManager.m

+1
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,7 @@ + (NSManagedObjectContext*)scratchManagedObjectContext {
590590
NSAssert(unlikelyError == nil, @"Internal Error 874-4408 %@", unlikelyError);
591591
scratchMOC.persistentStoreCoordinator = scratchPSC;
592592
[scratchPSC release];
593+
[scratchMOC autorelease];
593594

594595
return scratchMOC;
595596
}

0 commit comments

Comments
 (0)