Retained items and autorelease pool
Retained items and autorelease pool
- Subject: Retained items and autorelease pool
- From: Christian Mike <email@hidden>
- Date: Tue, 7 Aug 2001 08:50:32 -0500
I am still trying to figure out memory management. I have some
initialization code scattered throughout many routines that I am wanting to
protect with an autorelease pool. What happens to myString in the following
example?
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
... much code here...
... in some subroutine somewhere:
// myString is a loose global variable, not a class member of
anything
myString = [[NSString stringWithCString:someString] retain];
... much other code here ...
... back in earlier routine:
[pool release];
Did I just lose myString? If so, how do I allocate things that don't get
cleaned up by releasing the pool?
Thanks.
Michael Christian
Thomson multimedia Inc.