Thanks, Frank and Jonathan.
I fixed this bug and checked in to CVS.
Sat, Dec 10, 2005 8:49:52 PM, Jonathan Paisley wrote:
>On 10 Dec 2005, at 18:57, Frank Illenberger wrote:
>
>> I just checked my RubyCocoa app for memory leaks with the 'leaks'
>> command line tool. I observed lots of leaks that seem to come from
>> the conversion of ruby numbers to NSNumbers. The stack trace of the
>> leak always shows the following:
>
>> It looks like the objects returned from rbobj_to_nsobj never get
>> released. Is this a bug of RubyCocoa or am I doing something wrong?
>
>I think there is a bug. Specifically, rbnum_to_nsnum from
>ocdata_conv.m should return an autoreleased object:
>
Index: framework/src/objc/ocdata_conv.m
===================================================================
RCS file: /cvsroot/rubycocoa/src/framework/src/objc/ocdata_conv.m,v
retrieving revision 1.12
diff -u -r1.12 ocdata_conv.m
--- framework/src/objc/ocdata_conv.m 1 Nov 2005 16:18:55 -0000 1.12
+++ framework/src/objc/ocdata_conv.m 12 Dec 2005 13:09:34 -0000
@@ -343,11 +343,9 @@
{
BOOL result;
VALUE rbstr = rb_obj_as_string(rbval);
- id pool = [[NSAutoreleasePool alloc] init];
id nsstr = [NSString stringWithUTF8String: STR2CSTR(rbstr)];
- *nsval = [[NSDecimalNumber alloc] initWithString: nsstr];
+ *nsval = [NSDecimalNumber decimalNumberWithString: nsstr];
result = [(*nsval) isKindOfClass: [NSDecimalNumber class]];
- [pool release];
return result;
}
--
kimura wataru
|