• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
is there a memory leak?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: is there a memory leak?
      • From: Nick Zitzmann <email@hidden>
  • Prev by Date: Re: Bypassing the print settings panel.
  • Next by Date: Re: is there a memory leak?
  • Previous by thread: Re: Bypassing the print settings panel.
  • Next by thread: Re: is there a memory leak?
  • Index(es):
    • Date
    • Thread