2011-05-12 29 views
4

喜的朋友我已经在控制台消息(它不给错误或警告)只显示消息 这就像得到的消息只是内存泄漏

__NSAutoreleaseNoPool(): Object 0x6378190 of class HGMapPath autoreleased with no pool in place - just leaking 
__NSAutoreleaseNoPool(): Object 0x6379e00 of class HGMovingAnnotation autoreleased with no pool in place - just leaking 
__NSAutoreleaseNoPool(): Object 0x578f2e0 of class __NSCFSet autoreleased with no pool in place - just leaking 
__NSAutoreleaseNoPool(): Object 0x5790a00 of class __NSDate autoreleased with no pool in place - just leaking 
__NSAutoreleaseNoPool(): Object 0x5790ab0 of class __NSCFTimer autoreleased with no pool in place - just leaking 
__NSAutoreleaseNoPool(): Object 0x6348c90 of class UIView autoreleased with no pool in place - just leaking 
__NSAutoreleaseNoPool(): Object 0x633fb60 of class UILayoutContainerView autoreleased with no pool in place - just leaking 
__NSAutoreleaseNoPool(): Object 0x6379c10 of class __NSArrayI autoreleased with no pool in place - just leaking 
__NSAutoreleaseNoPool(): Object 0x5790e20 of class MKDirectionsRouteInfo autoreleased with no pool in place - just leaking 
__NSAutoreleaseNoPool(): Object 0x6371a40 of class MKDirectionsRouteInfo autoreleased with no pool in place - just leaking 
__NSAutoreleaseNoPool(): Object 0x63799c0 of class NSCFString autoreleased with no pool in place - just leaking 
__NSAutoreleaseNoPool(): Object 0x6371e30 of class NSCFNumber autoreleased with no pool in place - just leaking 
__NSAutoreleaseNoPool(): Object 0x636d850 of class NSCFNumber autoreleased with no pool in place - just leaking 
__NSAutoreleaseNoPool(): Object 0x5790cf0 of class __NSArrayI autoreleased with no pool in place - just leaking 
__NSAutoreleaseNoPool(): Object 0x5790d10 of class __NSArrayI autoreleased with no pool in place - just leaking 
__NSAutoreleaseNoPool(): Object 0x5790e90 of class NSCFNumber autoreleased with no pool in place - just leaking 
__NSAutoreleaseNoPool(): Object 0x5790d30 of class NSCFNumber autoreleased with no pool in place - just leaking 
__NSAutoreleaseNoPool(): Object 0x5790d40 of class NSCFNumber autoreleased with no pool in place - just leaking 
__NSAutoreleaseNoPool(): Object 0x5790d50 of class NSCFNumber autoreleased with no pool in place - just leaking 
__NSAutoreleaseNoPool(): Object 0x5790d60 of class NSCFNumber autoreleased with no pool in place - just leaking 
__NSAutoreleaseNoPool(): Object 0x5790d70 of class NSCFNumber autoreleased with no pool in place - just leaking 
__NSAutoreleaseNoPool(): Object 0x5790d80 of class NSCFNumber autoreleased with no pool in place - just leaking 
__NSAutoreleaseNoPool(): Object 0x5790d90 of class NSCFNumber autoreleased with no pool in place - just leaking 
__NSAutoreleaseNoPool(): Object 0x6379b40 of class __NSArrayI autoreleased with no pool in place - just leaking 
__NSAutoreleaseNoPool(): Object 0x6375300 of class CABasicAnimation autoreleased with no pool in place - just leaking 
__NSAutoreleaseNoPool(): Object 0x5790b40 of class CABasicAnimation autoreleased with no pool in place - just leaking 
__NSAutoreleaseNoPool(): Object 0x5790ed0 of class NSCFNumber autoreleased with no pool in place - just leaking 
__NSAutoreleaseNoPool(): Object 0x5790ee0 of class NSCFNumber autoreleased with no pool in place - just leaking 
__NSAutoreleaseNoPool(): Object 0x634d210 of class CABasicAnimation autoreleased with no pool in place - just leaking 
__NSAutoreleaseNoPool(): Object 0x6379b60 of class CABasicAnimation autoreleased with no pool in place - just leaking 
__NSAutoreleaseNoPool(): Object 0x637b870 of class __NSCFDictionary autoreleased with no pool in place - just leaking 
__NSAutoreleaseNoPool(): Object 0x6371960 of class NSThread autoreleased with no pool in place - just leaking 

我只是想知道为什么它正在发生。就是消息它会在未来造成问题。我可以如何解决这个问题我建议使用这个代码来解决这个问题。

//start tracking vehicle locations. In DEMO mode just read locations from the path... 
- (void) start 
{ 
    [self performSelectorInBackground:@selector(startTracking) withObject:nil]; 
} 

- (void) stop 
{ 
    [NSObject cancelPreviousPerformRequestsWithTarget:self]; 
    self.isMoving = NO; 
} 


- (void) startTracking 
{ 
    self.isMoving = YES; 

    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 

    for(int i=_currentPathPointIndex+1; i<path.pointCount; i++) 
    { 

    currentLocation = self.path.points[i]; 

    _distanceTravelled += MKMetersBetweenMapPoints(self.path.points[i], self.path.points[i-1]); 

     //send notification 
     [[NSNotificationCenter defaultCenter] postNotificationName:kObjectMovedNotification object:self]; 

     [NSThread sleepForTimeInterval : DEMO_SPEED]; 
    } 

    //finished moving along the path - send notification 
    [[NSNotificationCenter defaultCenter] postNotificationName:kObjectRechedEndOfPathNotification object:self]; 

    [pool drain]; 
} 

在此先感谢

+0

请正确格式化您的代码。 – 2011-05-12 05:53:50

回答

15

当得到“就地错误没有游泳池”设置调试器设置环境变量NSAutoreleaseHaltOnNoPool为YES时,进程启动。这会导致调试器在其中一个消息发出时中断。在这一点上,callstack应该帮助你找出你需要添加自动释放池的地方。

有关NSAutoreleaseHaltOnNoPool和许多其他调试工具的信息的细节可以在NSDebug.h中找到。

+0

如何将环境变量NSAutoreleaseHaltOnNoPool设置为YES – user733928 2011-05-12 07:02:43

+0

在XCode 3中,右键单击项目中的可执行文件并选择“Get Info”,然后单击参数选项卡,然后向该窗口的底部窗格添加一个变量。 – Evan 2011-05-14 02:15:17

+0

@Evan节省了很多时间..谢谢.. – xydev 2011-12-14 15:54:15