Re: GArray** as return value - howto to free from python?
- From: John Palmieri <johnp redhat com>
- To: Thomas Bechtold <thomasbechtold jpberlin de>
- Cc: python-hackers-list gnome org
- Subject: Re: GArray** as return value - howto to free from python?
- Date: Fri, 10 Jun 2011 14:11:35 -0400 (EDT)
----- Original Message -----
> Hi Tomeu,
>
> On Tue, 2011-06-07 at 14:59 +0200, Tomeu Vizoso wrote:
> > On Sat, Jun 4, 2011 at 13:31, Thomas Bechtold
> > <thomasbechtold jpberlin de> wrote:
> > >
> > > My question is, how i can free the GArray's from python?
> >
> > There's no way to do that explicitly, PyGObject will do that for you
> > once there isn't any reference to it.
>
> i tried to delete the result list (with the del() statement) and also
> tried to execute the garbage collection by hand. the memory was only
> freed when i exit the python interpreter.
>
> Maybe i use the wrong transfer-mode for introspection?
> i use:
> * @res_U: (element-type gdouble) (array) (out) (transfer full): array
> with voltage values
>
>
> Cheers,
>
> Tom
>
> _______________________________________________
> python-hackers-list mailing list
> python-hackers-list gnome org
> http://mail.gnome.org/mailman/listinfo/python-hackers-list
Hi Tom,
The new invoke-rewrite branch may fix this (though I am sure we have a bunch of other leaks). I'm guessing we aren't correctly freeing the g-array after marshalling since the g-array isn't wrapped by a python object and is technically a temporary object. To work around this you can simply change your transfer to (transfer container) though (transfer none) should work here too since the elements aren't pointers. In that case you would be treating the array as a way to transfer the data as opposed to an actual object with any significance. You then retain ownership of the array while relinquishing ownership of the contents. In this scenario, you can safely free the array yourself.
--
John (J5) Palmieri
Software Engineer
Red Hat, Inc.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]