is there a memory leak?
is there a memory leak?
- Subject: is there a memory leak?
- From: Leo <email@hidden>
- Date: Mon, 20 Nov 2006 15:34:34 +0800
Hi all:
here is my code:
- (NSString *)getContent:(NSString *)filename{
NSString *fileContent;
int cnt = 0;
static const int plainTextFileStringEncodingsSupported[] = {4,
-2147481296, -2147481280, -2147481087, -2147481085, -1};
while(plainTextFileStringEncodingsSupported[cnt] != -1) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSError *error;
NSStringEncoding encoding=plainTextFileStringEncodingsSupported[cnt];
NSString *stringFromFileAtPath=[[NSString alloc]
initWithContentsOfFile:filename encoding:encoding error:&error];
if(stringFromFileAtPath!=nil){
fileContent=stringFromFileAtPath;
stringFromFileAtPath=nil;
cnt=5;
}
else{
cnt++;
}
[pool release];
}
return fileContent;
}
when using mallocDebug to test this method and it displayed there is a
leak in "[[NSString alloc] initWithContentsOfFile:filename
encoding:encoding error:&error] ", does anybody can tell me why ? i
think there is no leak at all.
thank you!
Leo
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden