2011-01-28 1 views
0

나는 (예) 메모리 문제가 내가 정의의 UIView에서 다음과 같은 방법으로) 아이폰 OS에 새로운 오전 :할당이 취소 된 인스턴스 | "프로세스가 존재하지 않기 때문에 Malloc_history가 XYZ 프로세스를 검사 할 수 없습니다."

구현에 관련된 압력을 원하고 레이블을 그립니다

....  
@property (nonatomic, retain) NSString * pressureTextLabel; 
.... 

헤더 파일 촉감. 모두가 한이 다음과 같은 방법이 특정 터치 감지 된 압력을 업데이트하기 위해 컨트롤러에 의해 호출되지 않기 때문에 잘 작동

- (void)drawRect:(CGRect)theRect{ 
    CGRect rect = self.bounds; 
    CGRect ringRect = CGRectInset(rect, 100, 100); 

    // Outer ring. 
    UIBezierPath *path = [UIBezierPath bezierPathWithOvalInRect:ringRect]; 
    ringRect = CGRectInset(rect, 60, 60); 
    [path appendPath:[UIBezierPath bezierPathWithOvalInRect:ringRect]]; 
    path.usesEvenOddFillRule = YES; 
    [self.color set]; 
    [path fill]; 

    //text label 
    rect = CGRectMake(100, 20, 100, 100); 

    //This one seems to be the troublemaker 
    [pressureTextLabel drawInRect:rect withFont:[UIFont systemFontOfSize:14.0]]; 

} 

: 모든 손가락 터치는이 뷰의 객체를 생성합니다. shell malloc_history <PID> 0x17dfb0을 : 응용 프로그램이 충돌하면 내가 디버그 콘솔의 메모리 추적을 조사했다

*** -[CFString drawInRect:withFont:]: message sent to deallocated instance 0x16e8c0 

:

-(void) setTouchPressureTo: (float) pressure{ 

    pressureTextLabel = [NSString stringWithFormat:@"%f", pressure]; 
    [self setNeedsDisplay]; 

} 

나는 다음과 같은 오류가 발생합니다. 결과적으로 콘솔은 다음을 반환합니다.

malloc_history cannot examine process 5838 because the process does not이 있습니다.이

  1. 누군가가, 명백한이 유지 해제 문제를 여기에서 볼 수있다 : 그래서 여기에 질문

    ?

  2. malloc_history <PID> <Address> 은 어떻게 작동합니까?

시간을 내 주셔서 감사합니다.

기독교

+0

디버거에서 앱을 실행하면 충돌 후 프로세스가 계속 실행되어 malloc_history를 실행할 수 있습니다. –

답변

2

문제는 당신이 바르 (pressureTextLabel)에 오토 릴리즈 객체 (당신의 [NSString stringWithFormat...])을 할당하고있다. 대신 self.pressureLabel = ...처럼 속성 액세스를 사용해야합니다.

+0

케빈 감사합니다! 자체를 사용하여 작동하지만 나는 왜 내 코드가 문제를 일으키는 지 또는 왜 그것을 해결했는지 이해하지 못했다. – chriz

+0

[메모리 관리 프로그래밍 가이드] (http://developer.apple.com/library/mac/#documentation/cocoa/conceptual/MemoryMgmt/MemoryMgmt.html)를 읽어보십시오. –