[libvirt] [C# bindings] [PATCH]

Matthias Bolte matthias.bolte at googlemail.com
Sat Dec 18 10:14:58 UTC 2010


2010/12/16  <arnaud.champion at devatom.fr>:
>
>
> --------------------------------------------------
> From: "Matthias Bolte" <matthias.bolte at googlemail.com>
> Sent: Thursday, December 16, 2010 1:44 PM
> To: <arnaud.champion at devatom.fr>
> Cc: <libvir-list at redhat.com>
> Subject: Re: [libvirt] [C# bindings] [PATCH]
>
>> 2010/12/8  <arnaud.champion at devatom.fr>:
>>>
>>> Hi there,
>>>
>>> a long time since some update for C# bindings, sorry, I'm a little busy.
>>> Anyway here are some patches that correct marshaling around network
>>> functions, and as usual a new sample code related to network functions.
>>>
>>
>> 0001-Network-function-marhsalling-corrections.patch:
>> ACK and pushed it.
>>
>> There are GetUUIDString functions for other types too, do they need
>> the same treatment?
>>
>
> Yep, that's right.
>
>>
>> 0001-New-sample-virNetwork-for-network-related-samples.patch:
>> Is there a specific reason for naming the new example virNetworkd for
>> VisualStudio? I think this is a typo. Is that correct, then I will
>> rename it to virNetworks before pushing it?
>>
>
> Oops my mistake :S sorry. this should be "virNetwork"
>
>> The new example leaks _conn and _network. I'd like to see leak free
>> examples. Just yesterday I fixed a memory leak in the VirtualBox
>> driver that we inherited from the leaky example code in the VirtualBox
>> SDK.
>>
>
> :S I haven't understand (my poor english) what mean "leaks" ?
>

You leak a resource when you requested it but forget to give it back.
In C# you can't leak memory that you requested with new, because the
garbage collector automatically takes care of giving it back. In C you
request memory using malloc() and need to manually give it back using
free().

Each successful call to Connect.Open (or one of it's variations) must
be matched with a call to Connect.Close, otherwise you leak the
connection object. Same for the network object.

To do correct manual resource handling you'll need to close the
connection (if it's open) before opening it again in the connect
button method. Otherwise you'll open more and more connections until
libvirtd rejects new connections because it's at it's limit for open
connections. The same holds for the network object.

Matthias




More information about the libvir-list mailing list