• 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: Garbage Collection in commandline applications
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Garbage Collection in commandline applications


  • Subject: Re: Garbage Collection in commandline applications
  • From: Adam P Jenkins <email@hidden>
  • Date: Sun, 10 Feb 2008 01:59:47 -0500

Thanks Kyle,

I have seen the sentence you quoted, in the Garbage Collection Programming Guide, but that doesn't seem to help things. First of all, if the main thread wasn't registered with the garbage collector then calling
[[NSGarbageCollector defaultCollector] collectIfNeeded]
wouldn't do anything. Also, I did try invoking [NSThread self] and [NSThread currentThread] from my commandline program and it doesn't make a difference. GC only seems to occur if I explicitly call collectIfNeeded. I suppose I could always start a background thread which calls collectIfNeeded, but I was just wondering if anyone knows if that's what's happening in Cocoa applications, or if there's something better that should be done to make GC occur in the absence of a GUI thread.


Thanks again,
Adam


On Feb 9, 2008, at 2:27 AM, Kyle Sluder wrote:

On Feb 9, 2008 2:07 AM, Adam P Jenkins <email@hidden> wrote:
Now when you click the button you'll see the CPU usage go to 100%, but
the memory usage will stay constant. So it seems that something in
the run loop in the GUI thread needs to be running regularly in order
for GC to work.

From the documentation: "Only threads that have directly or indirectly performed an [NSThread self] operation are subject to garbage collection."

Not to mention, I don't know if the garbage collector simply considers
any object allocated within your stack frame to be valid.

--Kyle Sluder

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Garbage Collection in commandline applications (From: Adam P Jenkins <email@hidden>)
 >Re: Garbage Collection in commandline applications (From: "Kyle Sluder" <email@hidden>)

  • Prev by Date: Re: Memory management with arrays
  • Next by Date: Re: Memory management with arrays
  • Previous by thread: Re: Garbage Collection in commandline applications
  • Next by thread: CoreData: Save password securly
  • Index(es):
    • Date
    • Thread