Question about cleaning sessions. #2496
-
Example 'session', show us, that we can clean proxies manually. void
SessionI::destroy(const Ice::Current& current)
{
const lock_guard<mutex> sync(_mutex);
if (_destroy)
{
throw Ice::ObjectNotExistException(__FILE__, __LINE__);
}
_destroy = true;
cout << "The session " << _name << " is now destroyed." << endl;
try
{
current.adapter->remove(current.id);
for (const auto& p : _objs)
{
current.adapter->remove(p->ice_getIdentity());
}
}
catch (const Ice::ObjectAdapterDeactivatedException&)
{
// This method is called on shutdown of the server, in which
// case this exception is expected.
}
_objs.clear();
} What about auto proxie clean for destroyed objects ? and, i dont understand, how properly clean memory ? In example i have this architecture | - Session (Session can create Hello1, which can create Hello2, etc) How i can clean objects just by remove Prx of session, and Is it possible to do it so easily ? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Proxies are lightweight client-side objects that you use to make invocations on remote objects. You typically don't need to worry about cleaning them up. On the other hand, servants are server-side objects. If you create servants on behalf of a session, and register these servants with your object adapter, you should indeed cleanup these servants (cleanup meaning unregister them from the object adapter) when the session expires. And that's exactly what the code sample you included does.
Releasing/destroying a proxy has no effect whatsoever on the connection or the remote object. So if in your Hello1 server, you cleanup your proxy to an object in the Hello2 server, Hello2 won't notice anything. If your session example, what triggers the destruction of the session? Assuming you have one connection per session, you can close a connection manually from the client or intermediary server. See Let us know if anything remains unclear. |
Beta Was this translation helpful? Give feedback.
Proxies are lightweight client-side objects that you use to make invocations on remote objects. You typically don't need to worry about cleaning them up.
On the other hand, servants are server-side objects. If you create servants on behalf of a session, and register these servants with your object adapter, you should indeed cleanup these servants (cleanup meaning unregister them from the object adapter) when the session expires. And that's exactly what the code sample you included does.
Releasing/destroying a proxy has no effect whatsoeve…