in reply to C++ object & PERL garbage collection

if the object is new'd in MAIN; and passed to routines (via @_); no problems
if the object is new'd in a routine; and passed to MAIN (either by return,or global var) problems (dumps core)
the odd thing is that if the object is new'd in a routine and passed to another routine (via @_) no problems.


I can't quite follow that. If "the object is new'd in a routine and passed to another routine (via @_)" doesn't it first need to be passed to "MAIN" - which, you say, dumps core ? That is, how do you pass the object that was "new'd in a routine" to "another routine (via @_)" without first passing that object to "MAIN" ?

Sorry if I'm being dumb :-)

Anyway, seems to me that the issue is probably one that can only properly be fixed in the C++/XS code (rather than your perl code) ... but it's hard to tell from the info you've provided.

Cheers,
Rob
  • Comment on Re: C++ object & PERL garbage collection

Replies are listed 'Best First'.
Re^2: C++ object & PERL garbage collection
by Anonymous Monk on Sep 23, 2006 at 01:15 UTC
    but routines can call other routines, without first returning to MAIN, true?
    MAIN &routineA ROUTINEA &routineB ROUTINEB .....

    so a flow that works is :
    MAIN new C++object routineA(C++object) routineB(C++object)
    but a flow that does NOT work is :
    MAIN my C++object = routineA C++object->method ROUTINEA my C++object = new C++design return C++object

    yes, i agree with your last statement. ( that it is a C++ usage/style issue ) although we use SWIG, instead of XS.