Re: Does freeing a CMPIArray free the underlying objects?
Kirk Augustin <[email protected]>
| Newsgroups | gmane.network.open-pegasus.general |
|---|---|
| Message-ID | <[email protected]> |
That is cutting the answer a little short.
The whole paragraph reads:
{ ...
1.1.1 Memory
Ownership.
Due to its encapsulating nature, all complex data
structures are created by or via CMPI functions and should therefore be
released by or via CMPI. This enables the insulation of MIs from specific
memory management techniques used by the MB.
CMPI performs automatic release of its all encapsulated object used and/or created during an MI function invocation cycle, except for those structures having being
copied explicitly using the clone() function call by the MI.
Structures
having been copied must eventually be released by the MI explicitly using the release()function. This function can be used as well by long running indication threads or during invocation
cyclesto indicate that particular encapsulatedobjects (not
necessarily coned) are not needed anymore.
... }
And while it is true that eventually everything that was not cloned will get cleaned up, you should not wait for the garbage collection at the end of the invocation cycle.
It is better to release all object that are not needed anymore.
Kirk Augustin
11821 NW McNamee Rd
Portland, OR 97231
HM: 503-289-4356
>________________________________
> From: Jim Marshall <[email protected]>
>To: "Hwang, Johnny" <[email protected]>
>Cc: "[email protected]" <[email protected]>
>Sent: Monday, July 9, 2012 8:50 PM
>Subject: Re: Does freeing a CMPIArray free the underlying objects?
>
>
>Hwang, Johnny wrote:
>
>
>>Hello all,
>>
>>I’m wondering that, when I do the following call:
>>
>>CMPIArray *ptr;
>>…
>>ptr->ft->release(ptr);
>>
>>Where ptr is a CMPIArray of CMPI_instances, would the CMPI_instances also be released, or would I have to release them manually?
>>
>>Thanks for the clarification,
>>Johnny Hwang
>Technically you shouldn't have to call release on anything unless
you specifically call 'clone' on it. See section 3.1.6 of the 2.0
CMPI specification, here is the pertinent part (second paragraph)
>
>"CMPI performs automatic release of all its encapsulated objects
used and/or created during
>an MI function invocation cycle, except for those structures that
have been copied explicitly
>by the MI using the clone() function."
>
>So you do not *have* to call release on the array or its elements
but doing so should not cause any issues either. Of course this is
predicated on the fact that the array was created properly using the
CMPIBrokerEnc.newArray function.
>
>Jim
>
>--
>mail
>Jim Marshall
>Sr. Software Engineer
>
>
>
>
>
>