2010-04-15 7 views
0

내가 UITextView를 사용할 때 메모리 누수가 있지만 내가 왜 이해가 안 :아이폰 - UITextView 메모리 누수

UITextView *textView = [[UITextView alloc] initWithFrame:CGRectMake(20, 160, 280, 150)]; 
    textView.text = @"Hello World"; 
    textView.editable = FALSE; 
    [self.view addSubview:textView]; 
    [textView release]; 

누군가가 나를 도울 수 있습니까? : S

+3

에게 도움이 될 수 있습니다. 아마 그 누출은 다른 곳에서 온 것 같습니다. – kennytm

+0

왜 누설 된 것 같니? – Vladimir

답변

0

누출 기기를 사용할 때 누출이 있습니다. 확장 된 세부 정보 창에서 내 코드에 대한 마지막 호출은 UITextView이며이를 통해 UITextView의 alloc 및 init에 누수가 100 % 표시됩니다.

UITextView *textView = [[UITextView alloc] initWithFrame:CGRectMake(20, 160, 280, 150)]; 

    [textView setTextColor:[UIColor blackColor]]; 

    [textView setFont:[UIFont systemFontOfSize:12]]; 
    // For internationalization. 
    textView.text = NSLocalizedString(@"About-Description", @"");  

    textView.textAlignment = UITextAlignmentCenter; 

    textView.editable = FALSE; 
    [myView addSubview:textView]; 
    [textView release]; 

가 누출 악기 착각하고 나에게 잘못 라인을 표시하는 것이 가능 : 여기

전체 코드?

+0

Xcode에서 찾은 멋진 점 중 하나는 실행> 분석 도구입니다. 잠재적 인 메모리 누수가있는 곳을 알려줍니다. 그것은 "라인 12에서 생성 된 라인 54에서의 객체의 잠재적 인 메모리 누수"와 같은 것을 말합니다. – Zhang

0
UITextView *textView = [[UITextView alloc] initWithFrame:CGRectMake(20, 160, 280, 150)] autorelease] 

이 코드에는 누수가 없습니다 당신