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
On Mon, 2009-11-23 at 15:50 -0600, Douglas C. Schmidt wrote:
> 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
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
"Joost Kraaijeveld" <J.Kraa...@Askesis.nl> wrote in message
news:4b0a9d5e$0$6347$e4fe...@dreader16.news.xs4all.nl...
>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.
>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 --
-- dun...@grisby.org --
-- http://www.grisby.org --
>I have read the specification but I could not find an authoritative
>answer, hence the question.
Ok.
>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: d.sc...@vanderbilt.edu