why there is a memory leak in this method?
why there is a memory leak in this method?
- Subject: why there is a memory leak in this method?
- From: Leo <email@hidden>
- Date: Fri, 24 Nov 2006 14:21:46 +0800
Hi all:
I have a simple method:
- (NSString *)hTagString:(NSString *)source{
NSString *hTag=nil;
NSRange startRange=[source rangeOfString:@"<h1"
options:NSCaseInsensitiveSearch];
if(startRange.length!=0){
NSRange endRange=[source rangeOfString:@"</h1>"
options:NSCaseInsensitiveSearch];
NSRange tmpRange=[source rangeOfString:@">" options:NSCaseInsensitiveSearch
range:NSMakeRange(startRange.location+startRange.length,endRange.location-startRange.location-startRange.length)];
int start=tmpRange.location+tmpRange.length;
int len=endRange.location-tmpRange.location-tmpRange.length;
NSString *tmpTag=[source substringWithRange:NSMakeRange(start,len)];
NSAttributedString *test=[[[NSAttributedString alloc]
initWithHTML:[tmpTag dataUsingEncoding:[tmpTag fastestEncoding]]
documentAttributes:nil] autorelease];
hTag=[test string];
}
return hTag;
}
when i test it with MallocDebug and it displays there is a memory leak
in [NSAttributedString alloc] initWithHTML, but i have already
autorealease it, why it still has a leak? should i use NSAutoreleasePool?
Does anybody can help me, thank you.
Leo
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins (at) lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden