Protect objects of a C extension from GC

Discussion in 'Ruby' started by Detlef Reichl, Jul 29, 2007.

  1. 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
     
    Detlef Reichl, Jul 29, 2007
    #1
    1. Advertising

  2. Detlef Reichl

    Tim Hunter Guest

    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]
     
    Tim Hunter, Jul 29, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Anand
    Replies:
    3
    Views:
    898
    Tim Daneliuk
    Nov 8, 2003
  2. Christian Seberino
    Replies:
    3
    Views:
    1,189
    Christian Seberino
    Feb 5, 2004
  3. Steve
    Replies:
    3
    Views:
    26,997
    Steve
    Aug 25, 2006
  4. 7stud
    Replies:
    11
    Views:
    700
    Dennis Lee Bieber
    Mar 20, 2007
  5. Alessandro Zucchi

    Protect file with different extension from .aspx

    Alessandro Zucchi, Mar 24, 2005, in forum: ASP .Net Security
    Replies:
    6
    Views:
    168
    Juan Antonio Tubio
    Apr 12, 2005
Loading...

Share This Page