does ice have an internal memory monitoring mechanism similar to a COM reference counter ? #2348
-
How to delete unused objects on server. Example: interface Object
{
void setInt(int value); //just for example
int getInt();
};
interface Objects
{
Object createObject();
}; ObjectPrx ObjectsI::createObject(const Ice::Current& c)
{
ObjectPrx proxy = ObjectsPrx::uncheckedCast(c.adapter->addWithUUID(new ObjectI));
return proxy;
} And after 2 clients used UPD: class Callback : Ice::CloseCallback
{
void closed(const ConnectionPtr& con) override
{
//destroy object here
}
} but there can be this situation: interface Object
{
void setInt(int value);
int getInt();
};
interface Objects
{
Object createObject();
Object getItem(int index);
}; Client 1 connects and invokes createObject() How i can resolve this situation. The brain is boiling |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Hi, Ice does not provide a built-in mechanism for this. We typically recommend using a per-client session approach. The session can clean up the user resources once it become inactive. You can find a demo illustrating this technique at Ice session demo. |
Beta Was this translation helpful? Give feedback.
-
Another common solution is to not create servants (or services with IceRPC's terminology) after start-up. Your server just creates one or more servants at startup and that's it. Naturally, a server may still want to allocate some resources on behalf of a client (keep some "session data" in memory for each client). As @pepone commented, the typical solution is to associate this data with a session and clean it up when the session dies. And the simplest form of session is a connection: session lifetime = connection lifetime. Having just a fixed set of servants doesn't mean the server can't return new proxies from factory operations. For example: interface WidgetFactory
{
Widget* createWidget(string forClient);
} can return thousands of Widget proxies, all implemented by the same (default) servant. |
Beta Was this translation helpful? Give feedback.
Hi,
Ice does not provide a built-in mechanism for this. We typically recommend using a per-client session approach. The session can clean up the user resources once it become inactive.
You can find a demo illustrating this technique at Ice session demo.