bug-gnustep
[Top][All Lists]
Advanced

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

Re: [Fwd: Bug#206915: Memory leak in NSBitmapImageRep initWithBitmapData


From: Fred Kiefer
Subject: Re: [Fwd: Bug#206915: Memory leak in NSBitmapImageRep initWithBitmapDataPlanes]
Date: Fri, 29 Aug 2003 19:54:04 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20021204

The current behaviour, as unsatisfying as it may be to you, is the one described in the Apple documentation for this method:

If planes is not NULL and the array contains at least one data pointer, the object will only reference the image data; it won t copy it. The buffers won t be freed when the object is freed.

We should not change this behaviour, but perhaps you are able to change your usage of this method? One way to do so would be to create the bitmap image without supplying the data in this call, than you would ask it for the now create data and copy the real image values over too this. When the image contents changes later on it may be even sufficent to reuse the same object. This method is again described in the Apple documentation:

If planes is NULL or an array of NULL pointers, this method allocates enough memory to hold the image described by the other arguments. You can then obtain pointers to this memory (with the getBitmapDataPlanes: (page 146) or bitmapData (page 144) method) and fill in the image data. In this case, the allocated memory will belong to the object and will be freed when it s freed.

Hope this helps

Fred


Eric Heintzmann wrote:
Please, preserve the CC to -forwarded@bugs when you reply, so that the
debian bug tracking system will file your reply with the original
report.

-----Forwarded Message from the Debian Bug Tacking System-----

From: PUYDT Julien <julien.puydt@laposte.net>
To: submit@bugs.debian.org
Subject: Bug#206915: Memory leak in NSBitmapImageRep initWithBitmapDataPlanes
Date: 23 Aug 2003 21:33:11 +0200

Package: gnustep-gui
Version: 0.8.8-5

This is not an unknown problem, since the comment just before the
implementation is:
/* Note: If data is actaully passed to us in planes, we DO NOT own this
data and we DO NOT copy it. Just assume that it will always be available.
*/

I'm writing a little app that takes pictures from my webcam and then
displays them. I really want to be able to free the buffers I malloc'ed:
if the picture gets updated twenty times per second, this becomes a
terrible memory leak.

I got a quick look at the function, and I don't think it would be too
difficult to copy the data; the only things that prevent me to provide a
patch are:
* I don't feel comfortable enough with the way objc&gnustep handle
memory to know how to allocate&copy properly;
* the freeing of that memory must certainly be added somewhere, but I
don't know where.

perhaps I'll be able to do that quite soon, but not yet, sorry,

Snark on #gnustep





reply via email to

[Prev in Thread] Current Thread [Next in Thread]