• 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: GC Seems To Never Kick In
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: GC Seems To Never Kick In


  • Subject: Re: GC Seems To Never Kick In
  • From: Karl Moskowski <email@hidden>
  • Date: Thu, 12 Mar 2009 11:54:14 -0400


On 12-Mar-09, at 11:43 AM, Bill Bumgarner wrote:

On Mar 12, 2009, at 8:32 AM, Karl Moskowski wrote:
If I add something like this to the method's processing loop
	if (++block % 1000 == 0)
		objc_collect(OBJC_EXHAUSTIVE_COLLECTION);
memory usage stays reasonable in the Cocoa app.

I've tried other options in various combinations (e.g. objc_collect(OBJC_COLLECT_IF_NEEDED) and objc_clear_stack(OBJC_CLEAR_RESIDENT_STACK)), but only the above seems to help.

Any idea why GC seems to work automatically in a Foundation tool, but in a Cocoa app it sometimes needs manual invocation?

It sounds like the main event loop isn't running and triggering collections properly.


What happens if you kick it off and, say, click semi-spastically on the app's menu bar when it would otherwise die?

If the memory use stays reasonable, that is exactly what is happening.

If not, the workaround above is what would be recommended.

(This is a known issue -- if you search the archive, you'll find others have encountered it.)

Though known, feel free to file a bug. Knowing how many customers encounter a particular issue is very useful.


It looks like that is what's happening. I was launching the Cocoa app, picking the file from a menu item and letting it go while watching Activity Monitor. I just tried it with the objc_collect() commented out and periodically clicked a menu item; GC kicked in automatically every time.

I'll leave the objc_collect(OBJC_EXHAUSTIVE_COLLECTION) in, unless there's a better way.

Thanks, Bill.

----
Karl Moskowski <email@hidden>
Voodoo Ergonomics Inc. <http://voodooergonomics.com/>

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

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: 
 >GC Seems To Never Kick In (From: Karl Moskowski <email@hidden>)
 >Re: GC Seems To Never Kick In (From: Bill Bumgarner <email@hidden>)

  • Prev by Date: Re: GC Seems To Never Kick In
  • Next by Date: Re: NSGradient draws incorrectly in PDF context?
  • Previous by thread: Re: GC Seems To Never Kick In
  • Next by thread: Copy of NSDictionary is cleared when the original is cleared. Why?
  • Index(es):
    • Date
    • Thread