[Rubycocoa-devel 265] retainCount for ruby-side init

アーカイブの一覧に戻る

kimura wataru kimur****@i*****
Mon Jun 5 23:36:56 JST 2006


Hi,

When a subclass has init methods and a instance generated from
Cocoa world (eg.Nib), retainCount of the object becomes "2".
This behavior is different from one of without ruby-definition
init methods, but GC will release the object sometime.

I think this behavior is no problem. Don't you think? 

ex)

class SubClass < OSX::NSObject
  def init
    super_init
    # do something
    return self
  end
end

ObjC-side     Ruby-side    retainCount retained
-------------------------- ----------- --------
alloc                           1         NO
  |
init     ---->    + 
                  |
  +      <---- super_init
  |                             1         NO
(return) - - >    +       
                  |             2         YES
         < - - (return)

-  -  -  -  -  -  -  -  - 

              GC.start          1       (free)
-------------------------- ----------- --------

I wrote test cases for this case.

-- 
kimura wataru
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tc_retaincount.patch
Type: application/octet-stream
Size: 2687 bytes
Desc: not available
Url : http://lists.sourceforge.jp/mailman/archives/rubycocoa-devel/attachments/20060605/6e3fe152/attachment.obj 


More information about the Rubycocoa-devel mailing list
アーカイブの一覧に戻る