[#1207] warning in ruby extension eats memory — Eugene Scripnik <Eugene.Scripnik@...>

This message was posted to ruby-talk, but I didn't get responce from

22 messages 2003/07/01
[#1208] Re: warning in ruby extension eats memory — ts <decoux@...> 2003/07/01

>>>>> "E" == Eugene Scripnik <Eugene.Scripnik@itgrp.net> writes:

[#1209] Re: warning in ruby extension eats memory — Eugene Scripnik <Eugene.Scripnik@...> 2003/07/02

ts wrote:

[#1210] Re: warning in ruby extension eats memory — ts <decoux@...> 2003/07/02

>>>>> "E" == Eugene Scripnik <Eugene.Scripnik@itgrp.net> writes:

[#1211] Re: warning in ruby extension eats memory — Eugene Scripnik <Eugene.Scripnik@...> 2003/07/04

ts wrote:

[#1212] Re: warning in ruby extension eats memory — ts <decoux@...> 2003/07/04

>>>>> "E" == Eugene Scripnik <Eugene.Scripnik@itgrp.net> writes:

[#1213] Re: warning in ruby extension eats memory — Eugene Scripnik <Eugene.Scripnik@...> 2003/07/04

ts wrote:

[#1214] Re: warning in ruby extension eats memory — ts <decoux@...> 2003/07/04

>>>>> "E" == Eugene Scripnik <Eugene.Scripnik@itgrp.net> writes:

[#1215] Re: warning in ruby extension eats memory — Eugene Scripnik <Eugene.Scripnik@...> 2003/07/04

ts wrote:

[#1237] FTP.new with block — Gavin Sinclair <gsinclair@...>

Hi,

22 messages 2003/07/19
[#1238] Re: [Patch] FTP.new with block — ts <decoux@...> 2003/07/19

>>>>> "G" == Gavin Sinclair <gsinclair@soyabean.com.au> writes:

[#1240] Re: [Patch] FTP.new with block — Mathieu Bouchard <matju@...> 2003/07/19

[#1297] Fix for Bug 1058 — Markus Walser <walser@...>

Hi,

16 messages 2003/07/25

warning in ruby extension eats memory

From: Eugene Scripnik <Eugene.Scripnik@...>
Date: 2003-07-01 14:18:38 UTC
List: ruby-core #1207
This message was posted to ruby-talk, but I didn't get responce from 
there. Maybe I will get help here, because I don't understand what happens.

I've written extension in C for ruby and created test case for it. When 
I've run it ruby eat all memory. I've simplified code as I can and here 
is what I get:

 > cat test.c
#include "ruby.h"

typedef struct test_info {
     char *dummy;
} TestInfo;

static VALUE rb_cTest;

static VALUE test_free( TestInfo *info ) {
     rb_warn( "this warning makes ruby mad when used with test/unit" );
     if ( info ) free( info );
}

static VALUE test_s_allocate( VALUE klass ) {
     return Data_Wrap_Struct( klass, 0, test_free, 0 );
}

static VALUE test_initialize( VALUE self ) {
     DATA_PTR( self ) = ALLOC( TestInfo );
     return self;
}

void Init_mytest() {
     rb_cTest = rb_define_class( "MyTest", rb_cObject );
     rb_define_alloc_func( rb_cTest, test_s_allocate );
     rb_define_method( rb_cTest, "initialize", test_initialize, 0 );
}

 > cat extconf.rb
require "mkmf"

create_makefile("mytest")

 > cat test.rb
#!/usr/local/bin/ruby -w

require 'test/unit'
require 'mytest'

t = MyTest.new
 > ruby -v
ruby 1.8.0 (2003-06-20) [i386-freebsd5.1]

Note, if I remove "require 'test/unit'" line or rb_warn from extension 
everything is ok.

-- 
Eugene Scripnik
IT Group
Software Architect
Tel./Fax +380 (372) 58-43-10
email: Eugene.Scripnik@itgrp.net
http://www.itgrp.net/


In This Thread

Prev Next