Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Protect objects of a C extension from GC

Reply
Thread Tools

Protect objects of a C extension from GC

 
 
Detlef Reichl
Guest
Posts: n/a
 
      07-29-2007
Hi,

I'm writing on a video procession system. In this i have a C extension,
which creates ruby objects that encapsulate images. This objects are
passed with some ruby code to an other C extension which shall store
them for later output.

My problem is, that the GC destroys the objects while they are needed in
the future. I've tried to prevent this by calling

rb_gc_register_address (&myobject);

on the object and after i'm done with the object

rb_gc_unregister_address (&myobject);

But that seems to be ignorred.


Any hints about this?


TIA
detlef




 
Reply With Quote
 
 
 
 
Tim Hunter
Guest
Posts: n/a
 
      07-29-2007
Detlef Reichl wrote:
> Hi,
>
> I'm writing on a video procession system. In this i have a C extension,
> which creates ruby objects that encapsulate images. This objects are
> passed with some ruby code to an other C extension which shall store
> them for later output.
>
> My problem is, that the GC destroys the objects while they are needed in
> the future. I've tried to prevent this by calling
>
> rb_gc_register_address (&myobject);
>
> on the object and after i'm done with the object
>
> rb_gc_unregister_address (&myobject);
>
> But that seems to be ignorred.
>

Are you creating the objects using the Data_Make/Wrap/Get_Struct macros?
If so, establish a mark routine that GC can call so you can mark your
objects as being still in use by calling the rb_gc_mark function. See
Chapter 21 in the Pickaxe.

--
RMagick OS X Installer [http://rubyforge.org/projects/rmagick/]
RMagick Hints & Tips [http://rubyforge.org/forum/forum.php?forum_id=1618]
RMagick Installation FAQ [http://rmagick.rubyforge.org/install-faq.html]


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
class objects, method objects, function objects 7stud Python 11 03-20-2007 06:05 PM
New extension? saw extension .emf is it safe to open Jer Computer Support 5 10-08-2005 04:43 PM
Protect file with different extension from .aspx Alessandro Zucchi ASP .Net Security 6 04-12-2005 03:25 PM
C extension=> pow(2,1) gives DIFFERENT answers in different parts of C extension!?!?! Any ideas why? Christian Seberino Python 3 02-05-2004 04:36 AM
Unload extension modules when python22.dll unloads... [using C extension interpreter] Anand Python 3 11-08-2003 05:50 AM



Advertisments