[MacRuby-devel] [MacRuby] #578: Garbage Collector in 0.6

MacRuby ruby-noreply at macosforge.org
Sat Jan 30 07:33:56 PST 2010


#578: Garbage Collector in 0.6
---------------------------+------------------------------------------------
 Reporter:  jsn@…          |       Owner:  lsansonetti@…        
     Type:  defect         |      Status:  new                  
 Priority:  major          |   Milestone:  MacRuby 0.6          
Component:  MacRuby        |    Keywords:                       
---------------------------+------------------------------------------------

Comment(by jsn@…):

 I've been debugging on this all day now, so here's a quick status update
 in case some bright mind goes "AHA" and fixes it :-)

 It seems the GC is running just fine, but macruby holds on to way more
 data than it needs to.
 In the above example, the IO layer will :

 *) Cache the entire file in the first call to io_read, regardless of
 READ_BUFFER_SIZE.[[BR]]
 *) allocate (filesize / READ_BUFFER_SIZE) * ByteString objects.[[BR]]
 Effectively doubling the amount of RAM needed to read a file.

 All of the above objects live on long after the block has ended, and the
 file has been closed.

 I've had a little bit of success adding the following code to the end of
 io_close, which is basically just a brute force attempt at getting the GC
 to do something to the cached data.
 {{{
     if(io_struct->buf!=NULL){
         CFDataSetLength(io_struct->buf, 0);
         io_struct->buf = NULL;
         io_struct->buf_offset = 0;
     }
 }}}

-- 
Ticket URL: <http://www.macruby.org/trac/ticket/578#comment:1>
MacRuby <http://macruby.org/>



More information about the MacRuby-devel mailing list