Re: [gtkmm] how to free a pixbuf



Am 2003.10.15 17:47 schrieb(en) Silviu D Minut:
> The pixbuf's memory will be released when the last reference is
released.
> That's not for you to worry about because the RefPtr should worry
about it
> for you. If there seems to be a memory leak (not impossible - we've
seen
> them before) then please do make a simple-as-possible compileable
test case
> and put it in bugzilla.

I don't think it's RefPtr's fault. I am forced to maintain a RefPtr
for
the duration of the entire program, for display purposes (in an
expose_event callback), after the pixbuf has been read from the disk.
However, if I read a new image into the same pixbuf using
create_from_file(), the old memory is not released, as the RefPtr
still
exists, but new memory is allocated by create_from_file().

No, create_from_file() allocates a _new_ Pixbuf object. It is assigned
to the RefPtr which automatically derefences the old pixbuf. The old
pixbuf is released if it is the only reference to it. Probably another
reference is held to the old pixbuf somewhere in your program.
A test case would help to check this.

Regards,

  Martin



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]