|
From: Jonathan P. <jp...@dc...> - 2005-12-10 20:50:31
|
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:
static BOOL rbnum_to_nsnum(VALUE rbval, id* nsval)
{
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];
result = [(*nsval) isKindOfClass: [NSDecimalNumber class]];
[pool release];
return result; // **** should be return [result autorelease];
}
|