Edi Weitz edi@agharta.de writes:
However, if you do /not/ want to re-use the stream (which is obviously the case in your example as your function doesn't return the stream), you must of course always close it.
Sure, of course.
(when stream (ignore-errors (close stream)))))
Fair enough. FWIW, my production code looks exactly like this. (During my debugging I noticed that must-close was always t in my case.)
Regardless, if I make that change I still see the leak.
I have a data set I can send off-list if anyone is interested.
Cheers, Chris Dean
(defun simple-get (url) "Download the url using GET and return the body as a string." (handler-case (multiple-value-bind (stream code) (drakma:http-request url :want-stream t :keep-alive nil :method :get) (unwind-protect (and stream code (= code 200) (with-output-to-string (out) (do ((ch (read-char stream nil :eof) (read-char stream nil :eof))) ((not (characterp ch))) (princ ch out)))) (when stream (ignore-errors (close stream))))) (error (condition) (format t "Error ~s: ~a~%" url condition) nil)))