[Openmcl-devel] Cocoa and memory management
ron at flownet.com
Fri Jul 5 00:53:23 CDT 2013
I'm writing some code that grabs a stream of images from a camera and displays them in a window. The code looks roughly like this:
(multiple-value-bind (v p) (make-heap-ivector ...)
(let ((img (make-instance ns:ns-image :with-data
(make-instance ns:ns-data :with-bytes p :length (length v)))))
I'm trying to figure out if I have a memory leak because of not #/releasing the ns-data instance that I'm allocating, so I let this run for a while. According to top, I seem to have a leak because the image size grows. But when I stop the loop, close the listener it was running in, and call GC, the image size shrinks back down again.
It seems like there are two possibilities:
1. I'm allocating memory in the current listener's autorelease pool, and it's getting reclaimed when I close the listener. Except I'm not calling #/autorelease anywhere.
2. TOP is lying, and I'm not really leaking at all, but CCL is playing some games with virtual memory that fools top into thinking the image is growing when it's really not.
Any hints from those wise in the ways of objc memory management would be much appreciated.
More information about the Openmcl-devel