Other than the fact you're not checking for NULL when using
CFRelease(). I've learned to not trust any CF API to never return
NULL except CFSTR() (and I'm even hesitant on that).
But is this happening in another thread? It looks like this is a
cocoa application and if you're doing this in another thread, you
need to wrap the insides of the function with an NSAutoreleasePool,
much like almost anything at Jack in the Box.
UI elements shouldn't really be invoked in anything but the main
thread. At least, that's my understanding.
Ack, at 6/11/06, Richard Bannister said:
I've got some code calling CreateStandardAlert/RunStandardAlert
that is leaking a whole truck load of memory.
Have you tried printing out the retain counts on the strings you're
loading/using...
// Load strings
def = CFCopyLocalizedStringFromTable(CFSTR("Yes Please"), CFSTR
("Shareware"), "SW_DEFAULT");
can = CFCopyLocalizedStringFromTable(CFSTR("Maybe Later"), CFSTR
("Shareware"), "SW_CANCEL");
oth = CFCopyLocalizedStringFromTable(CFSTR("Reinstall"), CFSTR
("Shareware"), "SW_OTHER");
tit = CFCopyLocalizedStringFromTable(CFSTR("Brain Box is a
shareware product. Would you like to register now?"), CFSTR
("Shareware"), "SW_TITLE");
det = CFCopyLocalizedStringFromTable(CFSTR("This message appears
on program launch. It can be removed permanently by paying the
shareware fee instantly online via credit card."), CFSTR
("Shareware"), "SW_DETAIL");
// Release all the strings now, since they'll be retained above.
CFRelease(def);
CFRelease(can);
CFRelease(oth);
CFRelease(tit);
CFRelease(det);
-- here --
// Run the alert
if (err == noErr)
{
err = RunStandardAlert(alert, NULL, &itemHit);
-- and here --
}
}
Plus, as Rosyna mentioned, it would be a good idea to test that
CFCopyLocalizedStringFromTable did, in fact, return each of the
strings you wanted, and then release only those that came back as non-
null. If you're calling CFRelease on a null string, who knows what
that's doing to the heap.
An interesting test would also be to release all the strings after
calling RunStandardAlert to see if any of the other allocations get
cleaned up.
steve
_______________________________________________
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