Service destructor is not called when component is unloaded

asked 2016-11-18 03:56:48 -0500

disRecord gravatar image

This behavour can be reproduced by simple test

class MyService : public RTT::Service {
public:
    MyService(TaskContext* owner) : Service("myservice", owner)  {
         cout << "MyService constructor." << endl;    
    }

   ~MyService() {
        cout << "MyService destructor." << endl;
    }
};

and then load myservice in any component.

It seems to be caused by boost::shared_ptr loop in RTT::Service definition:

typedef std::map< std::string, shared_ptr > Services;
Services services;
...
shared_ptr parent;

What is cause of such design? Why should children owns it's parent? I can not imagine use case when we need preserve Service when coresponding component is being destructed.

edit retag flag offensive close merge delete

Comments

1

This looks like an OROCOS only question, is it not? I would suggest you try the OROCOS mailing list or users forum.

gvdhoorn gravatar image gvdhoorn  ( 2016-11-18 05:44:40 -0500 )edit

Well, it is. But I was unable to register on OROCOS forum (it does not like my email address). My friend was more lucky, but he has never received confirmation email. This behavour looks like a bug, but shared_ptr loop presents in code for too long to not be noticed.

disRecord gravatar image disRecord  ( 2016-11-19 04:50:35 -0500 )edit

It's a standard listserv list: orocos-users. That does not work for you?

gvdhoorn gravatar image gvdhoorn  ( 2016-11-19 05:11:43 -0500 )edit

Also: OROCOS development happens on Github: github.com/orocos, I'd post an issue there.

gvdhoorn gravatar image gvdhoorn  ( 2016-11-19 05:12:49 -0500 )edit

Thank you, but it seems it really hates my email address. I'll make github account and try to post an issue on github.

disRecord gravatar image disRecord  ( 2016-11-19 06:06:35 -0500 )edit