Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Mysterious crash in CFSTR()




On 2007 Mar 09, at 14:38, Dan Wright wrote:

Is InitCoreMidiDriver called more than once? Any chance MIDIClientCreate is releasing its first parameter? CFSTR only allocates a string the first time it is called, so you must either (a) never CFRelease a CFSTR string, or (b) remember to CFRetain it first.


Since Xcode 2.3, CFRetain() and CFRelease() have no effect on strings created via CFSTR().

Simple test:
Create a CFString via CFSTR().
Get its retain count.  The value is 0x10000000 I believe.
Retain it.
Check the retain count again.  No change.
Release it.
Check the retain count again.  No change.

BTW, this is a "magic number."  I did a test where I took a standard CFString, and kept retaining it until it hit the above number.  At that point CFRetain() and CFRelease() no longer had any effect.  On the other hand, I doubt many applications are going to need retain a string 2.7 billion times. :-D

Adin Hunter Baber

"Theory and practice are the same in theory, but different in practice."


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Carbon-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/carbon-dev/email@hidden

This email sent to email@hidden

References: 
 >Mysterious crash in CFSTR() (From: Anthony Kozar <email@hidden>)
 >Re: Mysterious crash in CFSTR() (From: Dan Wright <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.