Re: Does freeing a CMPIArray free the underlying objects?

Marek Szermutzky <[email protected]>
Newsgroups gmane.network.open-pegasus.general
Message-ID <OFC0779FA4.3517711E-ONC1257A37.002D92BB-C1257A37.002FDBD8@de.ibm.com>
To answer the original question "Does
freeing a CMPIArray free the underlying objects ?" ...



Yes, when calling release on CMPIArray,
the server will also release all underlying objects.

I recommend releasing objects not needed
anymore in a provider since that helps to avoid the effect of look-alike
memory leaks, meaning the server collecting lots and lots of objects plus
some dust on them ;)





Mit freundlichen Grüßen / Kind regards

Marek Szermutzky



Software Engineer / OpenPegasus Maintainer (PMC) and z/OS PlatformRep.

IBM Systems &Technology Group, Systems Software Development / z/OS
Capacity Management and Support

-------------------------------------------------------------------------------------------------------------------------------------------

IBM Deutschland

Schoenaicher Str. 220

71032 Boeblingen

Phone: +49-7031-16-5182

E-Mail: [email protected]

-------------------------------------------------------------------------------------------------------------------------------------------

IBM Deutschland Research & Development GmbH / Vorsitzender des Aufsichtsrats:
Martin Jetter

Geschäftsführung: Dirk Wittkopp

Sitz der Gesellschaft: Böblingen / Registergericht: Amtsgericht Stuttgart,
HRB 243294 







From: 
Kirk Augustin <[email protected]>

To: 
Jim Marshall <[email protected]>,
"Hwang, Johnny" <[email protected]>

Cc: 
"[email protected]"
<[email protected]>

Date: 
10.07.2012 07:11

Subject: 
Re: Does freeing
a CMPIArray free the underlying objects?



----------






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 cycles to indicate that particular encapsulated
objects (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

-- 

Jim Marshall

Sr. Software Engineer

http://ws-inc.com/
(unnamed) (image/jpeg, 15.3 KB) - not displayed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.