Memory corruption when going from 10.5 to 10.6
Memory corruption when going from 10.5 to 10.6
- Subject: Memory corruption when going from 10.5 to 10.6
- From: Gabriel Zachmann <email@hidden>
- Date: Wed, 7 Oct 2009 17:32:19 +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.
One 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 the Core Animation layer creation, so that it
looks like this:
CALayer * imgLayer = [[CALayer layer] retain];
...
[mySuperLayer replaceSublayer: old_imglayer with: imgLayer];
And that made the crash go away.
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?
(I'd rather stay with reference counting in my code, though.)
Best Regards,
Gabriel.
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden