Re: image-access memory leak

"Tim Bradshaw (as tfb at tfeb dot org)" <[email protected]>
Newsgroups gmane.lisp.lispworks.general
Message-ID <[email protected]>
FWIW I tried this using apply-in-pane-process-if-alive (on a displayed output-pane).  The result seems to be that if I sit in a loop calling test-load-image this way then LW explodes (I don't know how big it can get, but ... big), but the moment you stop doing that it shrinks again.  I guess this is some artifact of how cocoa does things, because if it was the LW GC I can't imagine it being this crappy.

--tim

> On 10 Jun 2025, at 19:17, Martin Simmons <[email protected]> wrote:
> 
> Are you calling test-load-image from the Listener?  LispWorks expects all
> CAPI/GP operations to be run on the thread that runs their interface.
> 
> It is possible that these GP image operations will work on other threads on
> the Mac (it all depends on the underlying Cocoa framework) but we can't
> guarantee it.  If you want to take the risk, then you could try wrapping
> objc:with-autorelease-pool around the code to see if that fixes the memory
> leak.
> 
> -- 
> Martin Simmons
> LispWorks Ltd
> http://www.lispworks.com/
> 
> 
> 
>>>>>> On Mon, 9 Jun 2025 14:05:23 +0000, Krupka Michal (as michal dot krupka at upol dot cz) said:
>> 
>> I need to analyze several thousands of png images (frames of a film). I read pixels via image-access. Here is a test function filling a vector with pixels of one image. The vector is created if not supplied, *test-pane* is a capi:output-pane.
>> 
>> (defun test-load-image (path &optional vector)
>>  (let* ((im (gp:load-image *test-pane* 
>>                            (gp:read-external-image path)
>>                            :editable t))
>>         (vec (if vector
>>                  vector
>>                (make-array (* (gp:image-height im) (gp:image-width im) 4) 
>>                            :element-type '(unsigned-byte 8))))
>>         (acc (gp:make-image-access *test-pane* im)))
>>    (gp:image-access-transfer-from-image acc)
>>    (gp:image-access-pixels-to-bgra acc vec)
>>    (gp:free-image-access acc)
>>    (gp:free-image *test-pane* im)
>>    vec))
>> 
>> Images are 1920 × 1080 pixels, about 1.4 MB each. I experience a huge memory leak (Gigabytes) when using this function about 1000 times. Any ideas? I use LWM 8.1.
>> 
>> Thanks,
>> 
>> Michal
>> 
>> _______________________________________________
>> Lisp Hug - the mailing list for LispWorks users
>> [email protected]
>> http://www.lispworks.com/support/lisp-hug.html
>> 
> 
> _______________________________________________
> Lisp Hug - the mailing list for LispWorks users
> [email protected]
> http://www.lispworks.com/support/lisp-hug.html


_______________________________________________
Lisp Hug - the mailing list for LispWorks users
[email protected]
http://www.lispworks.com/support/lisp-hug.html
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.