Robert P. wrote; >Ken Shmidheiser wrote: > > Assume we have created a CFArray, by definition immutable, holding > > an array of CFStrings, also by definition immutable. Being > > immutable, our CFStrings persist from creation until: > > A.) they are released by the user with CFRelease, or, > > B.) the program is quit and the OS 'gracefully' disposes the trash. > > > > So, in my CFArray-- it's a small one-- I create three elements: ><snip> > >I don't see any CFArray code in your posting. Paring your code to the >bone: > > > dim as CFStringRef cfRef1 > > cfRef1 = fn CFSTR( "Robert" ) > > cfRef1 = fn CFSTR( "Brian" ) > >It is OK to overwite cRef1 in this way because the strings are >generated by a CF function without "Create" or "Copy" in its name. >You don't own the string represented, and don't need to CFRelease it >(and indeed must not). > >By contrast consider: > cfRef1 = fn CFStringCreateWithPascalString( _kCFAllocatorDefault, >"Robert", _kCFStringEncodingMacRoman ) > cfRef1 = fn CFStringCreateWithPascalString( _kCFAllocatorDefault, >"Brian", _kCFStringEncodingMacRoman ) >Oops! After the second assignment the first string's reference is >lost, cannot be released, and is a memory leak. > > > > dim as CFMutableStringRef cfMutableRef1 > > cfMutableRef1 = fn CFStringCreateMutable ( _kCFAllocatorDefault, 0) > > CFStringReplaceAll ( cfMutableRef1, fn CFSTR( "Robert" ) ) > > CFStringReplaceAll ( cfMutableRef1, fn CFSTR( "Brian" ) ) > >This looks OK, but you should CFRelease( cfMutableRef1 ) as soon as >you have finished with it Thanks Robert. I need to learn to be a better housekeeper. Ken