• 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
Re: NSTextView & Leaking Memory
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTextView & Leaking Memory


  • Subject: Re: NSTextView & Leaking Memory
  • From: Chris Ross <email@hidden>
  • Date: Sat, 2 Aug 2003 19:41:12 +0100

I do this in my application.

Each loop is invoked using a menu item and therefore the release pool is run.
I know this because I have other objects that release themselves.

I cant help but feel that when I appendAttributedString: the string I append
is retain'ed but never released. Even if all the way up the tree of objects is
on auto release. It's doing my nut in =/

Chris

On Saturday, August 2, 2003, at 07:39 pm, publiclook wrote:

In Appkit applications, the default autorelease pool is only deallocated once per event cycle. If you are doing a lot of work inside a loop and never letting events be processed, the default pool is never dealocated and therefore does not release the objects it contains.

The solution is simple and well documented by Apple and others including this list:

Inside a loop:

{
// Create your own local pool
localPool = [[NSAutoreleasePool alloc] init];

// do something that autoreleases objects

// Cause local pool to be deallocated and it will release all contained objects
[localPool release];
}
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: NSTextView & Leaking Memory (From: publiclook <email@hidden>)

  • Prev by Date: Re: fade-out/fade-in
  • Next by Date: Re: Problem creating an NSButton subclass in Java
  • Previous by thread: Re: NSTextView & Leaking Memory
  • Next by thread: fixing table in NSScrollView line scroll amount
  • Index(es):
    • Date
    • Thread