• 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
Memory corruption when moving from 10.5 to 10.6
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Memory corruption when moving from 10.5 to 10.6


  • Subject: Memory corruption when moving from 10.5 to 10.6
  • From: Gabriel Zachmann <email@hidden>
  • Date: Wed, 7 Oct 2009 17:32:37 +0200

Dear list,

I am trying to make my screensaver work under 10.6.
However, it seems to me that under 10.6 there is memory corruption going on somewhere somehow.


I've set the "garbage collection" flag in XCode's project settings to "supported".
Otherwise, I haven't changed anything in my code.


I am using the conventional reference counting in my code, and everything works fine under 10.5.

However, under 10.6 I get completely erratic behavior; I have described some of it earlier.

Another example is the following.
At one point, System Preferences crashed, and the crash log showed this stack trace:
0 libobjc.A.dylib 0x00007fff8249533c objc_msgSend + 40
1 com.apple.QuartzCore 0x00007fff87ea5820 CABackingStoreUpdate + 2427
2 com.apple.QuartzCore 0x00007fff87ea4abf -[CALayer _display] + 837
3 com.apple.QuartzCore 0x00007fff87e635eb CALayerDisplayIfNeeded + 524
4 com.apple.QuartzCore 0x00007fff87e62a62 CA::Context::commit_transaction(CA::Transaction*) + 328
5 com.apple.QuartzCore 0x00007fff87e626b6 CA::Transaction::commit() + 314
6 com.apple.CoreFoundation 0x00007fff87015437 __CFRunLoopDoObservers + 519
7 com.apple.CoreFoundation 0x00007fff86ff105f CFRunLoopRunSpecific + 607
8 com.apple.HIToolbox 0x00007fff815bac4e RunCurrentEventLoopInMode + 333


So I added 'retain' to this line of code
    CALayer * imgLayer = [CALayer layer];
so that it looked like this
    CALayer * imgLayer = [[CALayer layer] retain];
And that made the crash go away.
(The imglayer gets added to a superlayer by replaceSublayer:with:)

Of course, the fact that it crashed somewhere in -[CALayer _display] might be just by chance, and a crash somewhere else might have been as likely.

Another observation is that when I put this in initWithFrame:
	[[NSGarbageCollector defaultCollector] disable];
then my screensaver works fine again.
(However, the memory footprint keeps increasing.)


I tried to check my code for any memory corruption under 10.5 using valgrind.
But that revealed nothing bad in my code.


I also read the "Garbage Collection Programming Guide", but I couldn't find any hint that I should need to change anything in my code.


Is there any tool that might help with finding any memory corruption bugs in my code?
(remember that it's a screensaver)


Or do I need to do anything in the project settings or in my code to make it work under 10.6 with garbage collection supported?
(I'd rather stay with reference counting in my code, though.)


Best Regards,
Gabriel.

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

  • Prev by Date: Re: Triggering a Method when a Core Data Property is Altered.
  • Next by Date: Re: Triggering a Method when a Core Data Property is Altered.
  • Previous by thread: [iPhone] In App Purchase Voodoo?
  • Next by thread: Strange Core Data problem after upgrade
  • Index(es):
    • Date
    • Thread