Discussion:
Memory management in ORB implementation
(too old to reply)
Joost Kraaijeveld
2009-11-23 14:33:43 UTC
Permalink
Hi,

I am curious about the memory management in an ORB implementation. If an
interface returns a pointer (_ptr) to an object that is part of an ORB's
implementation, who owns that pointer and is responsible for the
deletion of that pointer, e.g. a pointer returned from
orb->resolve_initial_references()? Or are all the local objects
reference counted somehow and is the callee responsible for bumping the
reference count so that the caller can safely store the pointers in a _var?

Or is there a kind soul somewhere with a pointer to some docs where I
can read about the memory management of an ORB implementation?

TIA

Joost
Joost Kraaijeveld
2009-11-24 11:53:53 UTC
Permalink
Hi Douglas,
http://www.omg.org/technology/documents/formal/c++.htm
for the CORBA C++ language mapping specification, which explains how
all of this stuff works.
I have read the specification but I could not find an authoritative
answer, hence the question.

Maybe I was not clear enough but I was talking about the implementation
of the ORB itself. In that context I wondered who owns the pointer that
is returned from for example "resolve_initial_references": is it the
caller or the callee's responsibility to bump the reference count (if
any), should the caller use "delete" or "Corba::release" etc. I assume
that the callee bumps the reference count for reference counted object
so that the returned pointer can safely be stored in a _var without any
fuss. Is that correct?

TIA

Joost
Douglas C. Schmidt
2009-11-24 13:56:47 UTC
Permalink
Hi Joost,
Post by Joost Kraaijeveld
I have read the specification but I could not find an authoritative
answer, hence the question.
Ok.
Post by Joost Kraaijeveld
Maybe I was not clear enough but I was talking about the implementation
of the ORB itself. In that context I wondered who owns the pointer that
is returned from for example "resolve_initial_references": is it the
caller or the callee's responsibility to bump the reference count (if
any), should the caller use "delete" or "Corba::release" etc. I assume
that the callee bumps the reference count for reference counted object
so that the returned pointer can safely be stored in a _var without any
fuss. Is that correct?
Yes, that is correct. If you use the *_var types then there's no fuss
(for the typical/simple cases). If you use the *_ptr types, however,
then the caller is responsible for managing the memory via release().

Thanks,

Doug
--
Dr. Douglas C. Schmidt Professor and Associate Chair
Electrical Engineering and Computer Science TEL: (615) 343-8197
Vanderbilt University WEB: www.dre.vanderbilt.edu/~schmidt
Nashville, TN 37203 NET: ***@vanderbilt.edu
Johnny Willemsen
2009-11-24 12:46:00 UTC
Permalink
Hi,

In the past there was no reference counting for local objects, the 1.2 C++
mapping did change this, local objects are now reference counted by default.
That is something we changed in TAO some time ago

Johnny
www.theaceorb.nl
Post by Joost Kraaijeveld
Hi,
I am curious about the memory management in an ORB implementation. If an
interface returns a pointer (_ptr) to an object that is part of an ORB's
implementation, who owns that pointer and is responsible for the
deletion of that pointer, e.g. a pointer returned from
orb->resolve_initial_references()? Or are all the local objects
reference counted somehow and is the callee responsible for bumping the
reference count so that the caller can safely store the pointers in a _var?
Or is there a kind soul somewhere with a pointer to some docs where I
can read about the memory management of an ORB implementation?
TIA
Joost
Duncan Grisby
2009-11-24 13:07:10 UTC
Permalink
Post by Joost Kraaijeveld
I am curious about the memory management in an ORB implementation. If an
interface returns a pointer (_ptr) to an object that is part of an ORB's
implementation, who owns that pointer and is responsible for the
deletion of that pointer, e.g. a pointer returned from
orb->resolve_initial_references()? Or are all the local objects
reference counted somehow and is the callee responsible for bumping the
reference count so that the caller can safely store the pointers in a _var?
The caller takes ownership of the object in that case, and is
responsible for releasing it.
Post by Joost Kraaijeveld
Or is there a kind soul somewhere with a pointer to some docs where I
can read about the memory management of an ORB implementation?
The C++ mapping specification gives you all the rules:

http://www.omg.org/spec/CPP/1.2/

Cheers,

Duncan.
--
-- Duncan Grisby --
-- ***@grisby.org --
-- http://www.grisby.org --
Loading...