• 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
Retained items and autorelease pool
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.


  • Prev by Date: Re: Autorelease pool - was Beginners question regarding NSFileHandle
  • Next by Date: Re: Wake and sleep notification
  • Previous by thread: NSFormatter bug (workaround)
  • Next by thread: Re: Retained items and autorelease pool
  • Index(es):
    • Date
    • Thread