From: "Asbjørn Reglund Thorsen" Date: 2005-01-15T21:10:20+09:00 Subject: [n00b] Garbage collection, Ruby C++ and SWIG I`m having trouble with an interface to a c++ library. It seems like Ruby`s GC is collecting objects that it shouldn`t. I have read the SWIG-Ruby documentation on the matter, but I am unsure of where to put the markfunc , and how to get it to interact with my program. My interface file : mHeat1.i My Ruby code : run.rb require 'mHeat1' menu = MHeat1::MenuSystem.new menu.init("Ruby Interface", "This is so cool !") heat = MHeat1::Heat1.new heat.define(menu) heat.scan heat.solveProblem heat.resultReport The problem is the MenuSystem, I found out by using gdb: gdb ruby (gdb)run run.rb ... Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 16384 (LWP 1345)] 0x00000089 in ?? () (gdb) where #0 0x00000089 in ?? () #1 0x40388c19 in free_MenuSystem () from ./mHeat1.so #2 0x0806f636 in rb_gc_call_finalizer_at_exit () at gc.c:1858 #3 0x08053e34 in ruby_finalize_1 () at eval.c:1418 #4 0x08053f43 in ruby_cleanup (ex=0) at eval.c:1453 #5 0x08054081 in ruby_stop (ex=135573240) at eval.c:1484 #6 0x080540ef in ruby_run () at eval.c:1505 #7 0x08052245 in main (argc=135573240, argv=0x814aef8, envp=0xbffff020) at main.c:46