Memory Mania Revisted
Memory Mania Revisted
- Subject: Memory Mania Revisted
- From: email@hidden
- Date: Thu, 7 Feb 2002 21:48:51 -0800
Ok, I did a little reading up on memory allocation, release/retain
stuff, but I'm still a little bit confused about the specifics...
Here's some hypothetical code:
NSDecimalNumber *myDN = (NSDecimalNumber *)[NSDecimalNumber
numberWithFloat:2.5];
NSDecimalNumber *myOtherDN = (NSDecimalNumber *)[NSDecimalNumber
numberWithFloat:4.5];
// Suppose I want to take these two NSDecimalNumbers and add one to the
other like this:
myDN = [myDN decimalNumberByAdding:myOtherDN];
...
OK... I _think_ there's a leak here, because - (NSDecimalNumber
*)decimalNumberByAdding:(NSDecimalNumber *)dn creates a new instance of
NSDecimalNumber, right? then the original myDN memory is lost because
I've reassigned the pointer without deallocating this. My question is,
what is the best strategy for eliminating this leak? I do this step a
lot in my code, and I don't want to have to write 4 lines whenever I do
it...
Thanks in advance :-)
The not-as-hopeless-as-before Cocoa newbie
-Kevin Perry
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.