[omniORB] Object lifetime/release & Java GC confusion

Jelle jelle at defekt.nl
Sun Sep 14 23:10:29 BST 2003


Hi list,

I'm confused regarding the use of CORBA::release() and object lifespan
etc..  Suppose I got the following idl

interface Hello {
	string say_hello();
};
interface Server {
	Hello get_hello();
};

This is the server implementation in C++, just as in the examples.

class Hello_i : public POA_Server
{
public:
	inline Hello_i() {}
	virtual ~Hello_i() {}
	virtual char* say_hello()
	{
		return CORBA::string_dup("hello there");
	}
};

class Server_i : public POA_Server, public PortableServer::RefCountServantBase
{
public:
	Hello_i _hello;
	Server_i()
	{
		_hello = new Hello_i();
	}
	virtual ~Server_i()
	{
		delete _hello;
	}
	virtual Hello_ptr get_hello()
	{
		return _hello->_this();
	}
};

Now, if I call get_hello() from the (Java) client, what should I do?
call CORBA::release from the java client if I'm done with the object?

And suppose I need to construct a new Hello_i instance each time
get_hello() is called, how can I make sure, from the client's side, that
all the Hello_i instances are deleted on the server side.

And how does the java garbage collection mechanism fit into all this?
Are objects released automatically when they are garbage collected?

Thanks a lot,
bye, Jelle, confused :)



More information about the omniORB-list mailing list