|
Re: how to prevent objects from being garbage collected.: msg#00124programming.swig
On 2004.05.24 13:29, meinrad recheis wrote: when ruby exits, all objects will be deleted and their C++ destructors get called. if objects that are owned by others (in C++) are deleted bevore their owners the owners will try to free them again and that leads to memory access errors. Hi, I think the real question is: how can you prevent Ruby and C++ from thinking they both own the object. Are the objects created on the C++ side and returned through a swigged function? In this case, the wrappers are generated so that Ruby knows it should'n call the destructor; therefore, you shouldn't have the problem. Instead, if objects are created on the Ruby side and passed to other objects who then take ownership and will take care to delete them, you should find a way to tell Ruby they're no longer owned, which might be a problem. In this case, you could write a factory function and use that (instead of their constructors) to instantiate your objects. This way you would return to the first case (object returned from C++, Ruby knows not to delete it.) Later, Luigi _______________________________________________ Swig maillist - Swig@xxxxxxxxxxxxxxx http://mailman.cs.uchicago.edu/mailman/listinfo/swig |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: how to prevent objects from being garbage collected.: 00124, Henri Asseily |
|---|---|
| Next by Date: | trouble swigging a library: 00124, Martin F Krafft |
| Previous by Thread: | Re: how to prevent objects from being garbage collected.i: 00124, Henri Asseily |
| Next by Thread: | Re: how to prevent objects from being garbage collected.: 00124, Marcelo Matus |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |