• 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: Memory Leak while using NSTask repeatedly
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Memory Leak while using NSTask repeatedly


  • Subject: Re: Memory Leak while using NSTask repeatedly
  • From: Cameron Hayne <email@hidden>
  • Date: Thu, 16 Oct 2003 14:46:10 -0400

On 16/10/03 12:42 PM, "Huyler, Christopher M" <email@hidden>
wrote:

> Inside my awakefromnib function I create a new thread
> and execute a nowait function that runs an infinite loop.
> [...]
> basically it calls "ps" over and over again to see whether our
> services are active. If I comment out the "task launch" and "task
> waitUntilExit" and run it, I don't get any memory leaks. However, if I
> uncomment those lines, I start loosing 2-4 Kb a second (each time the
> loop runs).
>
> Is there some more clean-up that I am missing?

Yes. The whole "autorelease" mechanism relies on the NSAutoreleasePool
getting emptied. You need to put
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc]init]
at the beginning of your loop and
[pool release]
at the end.
See:
http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/Concept
s/AutoreleasePools.html

--
Cameron Hayne (email@hidden)
Hayne of Tintagel
_______________________________________________
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: 
 >Memory Leak while using NSTask repeatedly (From: "Huyler, Christopher M" <email@hidden>)

  • Prev by Date: Re: Restraining window movement + gridding
  • Next by Date: Re: Restraining window movement + gridding
  • Previous by thread: Re: Memory Leak while using NSTask repeatedly
  • Next by thread: RE: Memory Leak while using NSTask repeatedly
  • Index(es):
    • Date
    • Thread