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: RunStandardAlert leaking memory all over the place?



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.

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.

2006-06-11 14:34:46.919 Brain Box[3527] *** _NSAutoreleaseNoPool(): Object 0x356b00 of class NSCarbonWindowContentView autoreleased with no pool in place - just leaking
2006-06-11 14:34:46.921 Brain Box[3527] *** _NSAutoreleaseNoPool(): Object 0xa37217d0 of class NSCFString autoreleased with no pool in place - just leaking
2006-06-11 14:34:46.922 Brain Box[3527] *** _NSAutoreleaseNoPool(): Object 0x358b60 of class NSCFDictionary autoreleased with no pool in place - just leaking
2006-06-11 14:34:46.922 Brain Box[3527] *** _NSAutoreleaseNoPool(): Object 0x3331b0 of class NSCFArray autoreleased with no pool in place - just leaking
2006-06-11 14:34:46.922 Brain Box[3527] *** _NSAutoreleaseNoPool(): Object 0x3528c0 of class NSCFString autoreleased with no pool in place - just leaking
2006-06-11 14:34:46.922 Brain Box[3527] *** _NSAutoreleaseNoPool(): Object 0x3529c0 of class NSCFString autoreleased with no pool in place - just leaking
2006-06-11 14:34:46.922 Brain Box[3527] *** _NSAutoreleaseNoPool(): Object 0x358b90 of class NSPathStore2 autoreleased with no pool in place - just leaking
2006-06-11 14:34:46.922 Brain Box[3527] *** _NSAutoreleaseNoPool(): Object 0x358c60 of class NSPathStore2 autoreleased with no pool in place - just leaking
2006-06-11 14:34:46.922 Brain Box[3527] *** _NSAutoreleaseNoPool(): Object 0x358bc0 of class NSCFString autoreleased with no pool in place - just leaking
2006-06-11 14:34:46.922 Brain Box[3527] *** _NSAutoreleaseNoPool(): Object 0x345b40 of class NSCFString autoreleased with no pool in place - just leaking
2006-06-11 14:34:46.922 Brain Box[3527] *** _NSAutoreleaseNoPool(): Object 0x358c10 of class NSCFArray autoreleased with no pool in place - just leaking
2006-06-11 14:34:46.922 Brain Box[3527] *** _NSAutoreleaseNoPool(): Object 0x358d20 of class NSPathStore2 autoreleased with no pool in place - just leaking
2006-06-11 14:34:46.923 Brain Box[3527] *** _NSAutoreleaseNoPool(): Object 0x358ca0 of class NSPathStore2 autoreleased with no pool in place - just leaking
2006-06-11 14:34:46.923 Brain Box[3527] *** _NSAutoreleaseNoPool(): Object 0x358d80 of class NSPathStore2 autoreleased with no pool in place - just leaking
2006-06-11 14:34:46.923 Brain Box[3527] *** _NSAutoreleaseNoPool(): Object 0xa3721910 of class NSCFString autoreleased with no pool in place - just leaking
2006-06-11 14:34:46.925 Brain Box[3527] *** _NSAutoreleaseNoPool(): Object 0xa3226f58 of class NSCFString autoreleased with no pool in place - just leaking


The code is as follows:

void shareware_annoy(void)
{
AlertStdCFStringAlertParamRec paramRec;
OSStatus err;
DialogRef alert;
DialogItemIndex itemHit;
CFStringRef def, can, oth, tit, det;


// 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");


// Get defaults
GetStandardAlertDefaultParams(&paramRec, kStdCFStringAlertVersionOne);
paramRec.defaultText = def;
paramRec.cancelText = can;
paramRec.otherText = oth;
err = CreateStandardAlert(kAlertCautionAlert, tit, det, &paramRec, &alert);


	// Release all the strings now, since they'll be retained above.
	CFRelease(def);
	CFRelease(can);
	CFRelease(oth);
	CFRelease(tit);
	CFRelease(det);

	// Run the alert
	if (err == noErr)
	{
		err = RunStandardAlert(alert, NULL, &itemHit);
	}
}

Has anyone seen this one before? What am I doing wrong?

Many thanks,

--


Sincerely, Rosyna Keller Technical Support/Holy Knight/Always needs a hug

Unsanity: Unsane Tools for Insanely Great People

It's either this, or imagining Phil Schiller in a thong.
_______________________________________________
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: 
 >RunStandardAlert leaking memory all over the place? (From: Richard Bannister <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.