How to delete servants?
szyk100
szyk100 at o2.pl
Thu Nov 26 20:10:53 GMT 2015
Hi
[[ Current state ]]
I am writing Chat program. Now connection is done and text messages flow between client and server.
[[ Problem ]]
Problem is with memory management. In every servant class I add line to destructor:
cout<<"XYZ deleted"<<endl;
Where XYZ is the class name.
But apparently no one destructor is called.
[[ Example ]]
I have only 4 servants. But I show how I use two of them (RoomControllerImp and UserImp).
RoomControllerImp is proxy class between UserImp (client side) and RoomImp (server side). This class is created by server and used by client.
In client side Qt window class WinMainC constructor I called:
mUser->mRoomController = mRoom->joinUser(mUser_var);
mUser::mRoomController is TCzat::RoomController_var class.
mRoomController is used only by UserImp class (methods: message(), removeUser(), users()).
And finally I close application window and call:
WinMainC::~WinMainC()
{
delete ui;
mUser->destroy();
mPoa->deactivate_object(*mUserObjectID);
mUser = 0; // deleted by mUser_var
}
In WinMainC I have 2 variables for UserImp:
UserImp* mUser;
TCzat::User_var mUser_var;
First is for operations, and second is for automatic deletion (after WinMainC::~WinMainC()).
And in UserImp::destroy():
mRoomController->removeUser(_this());
mRoomController->destroy();
In the last call (RoomControllerImp::destroy()) I call:
mPoa->deactivate_object(*mPoa->reference_to_id(_this()));
And I suspect that WinMainC::mUser_var delete WinMainC::mUser and it will delete TCzat::RoomController_var from UserImp and finally TCzat::RoomController_var will delete RoomControllerImp.
But it does not! Why? I have no idea... Because as far as I know _var objects count references (contray to _ptr) and deletes when it's number counts down to 0. That is my case, but neither UserImp::~UserImp nor RoomControllerImp::~RoomControllerImp() is called.
Or maybe should I call ~UserImp and ~RoomControllerImp() explicitly (by delete objects)?
regards
Szyk Cech
More information about the omniORB-list
mailing list