From enonymoos at gmail.com Thu Sep 28 20:39:41 2006 From: enonymoos at gmail.com (Nonny Mouse) Date: Thu, 28 Sep 2006 13:39:41 -0700 Subject: [nio-devel] NIO memory leak patch Message-ID: <8229e4e80609281339g1336db7fp549c85b3a6be3f2e@mail.gmail.com> Hi All, Had a look over the NIO work, running ab2(apache-bench - http://httpd.apache.org/docs/2.2/programs/ab.html)) against it, and it seems to hold up pretty well when compared with apache/mod_lisp2 and araneida (I'll post some results later on). I ran into a memory leak, which the following patch fixed for me. The patch is against the nio-20060204.tar.gz (doesn't look like the cvs is up-to-date?) from the http://common-lisp.net/project/nio/ website. I'm no lisp expert, so any feedback appreciated. Cheers, Paul. nio-20060204$ diff async-fd.lisp.orig async-fd.lisp 184c184 < (with-slots (write-queue read-fd write-fd) async-fd --- > (with-slots (write-queue read-fd write-fd foreign-read-buffer) async-fd 189a190 > (foreign-free foreign-read-buffer) 216,220c217,226 < ;; remove entries that have been fully written < (setf write-queue (remove-if #'(lambda (x) < (with-slots (size written) x < (= size written))) < write-queue)) --- > ;; remove (and dealloc buffers) of entries that have been fully written > (let ((unfinished-entries NIL)) > (setf write-queue > (nreverse > (dolist (entry write-queue unfinished-entries) > (with-slots (size written) entry > (if (= size written) > (with-slots (buffer) entry > (foreign-free buffer)) > (push entry unfinished-entries))))))) -------------- next part -------------- An HTML attachment was scrubbed... URL: From risto.laakso at gmail.com Thu Sep 28 20:50:18 2006 From: risto.laakso at gmail.com (Risto Laakso) Date: Thu, 28 Sep 2006 23:50:18 +0300 Subject: [nio-devel] NIO memory leak patch In-Reply-To: <8229e4e80609281339g1336db7fp549c85b3a6be3f2e@mail.gmail.com> References: <8229e4e80609281339g1336db7fp549c85b3a6be3f2e@mail.gmail.com> Message-ID: <439fc7a30609281350s7a310b4bs96f0ec7bd666b18e@mail.gmail.com> Hello, thanks for the patch; I had marked to my to-do that: "- current nio is leaking memory: 1) foreign read buffer is not freed when async-fd is closed; 2) foreign write buffers (created in map-to-foreign) aren't freed, there's just code to (remove-if #'buffer-written buffers). " but haven't had time to fix it. I think your patch fixes both cases. Thanks, Risto 2006/9/28, Nonny Mouse : > Hi All, > > Had a look over the NIO work, running ab2(apache-bench - > http://httpd.apache.org/docs/2.2/programs/ab.html) ) > against it, and it seems to hold up pretty well when compared with > apache/mod_lisp2 and araneida (I'll post some results later on). > > I ran into a memory leak, which the following patch fixed for me. The patch > is against the nio-20060204.tar.gz (doesn't look like the cvs is > up-to-date?) from the http://common-lisp.net/project/nio/ > website. > > I'm no lisp expert, so any feedback appreciated. > > Cheers, > > Paul. > > nio-20060204$ diff async-fd.lisp.orig async-fd.lisp > 184c184 > < (with-slots (write-queue read-fd write-fd) async-fd > --- > > (with-slots (write-queue read-fd write-fd foreign-read-buffer) async-fd > 189a190 > > (foreign-free foreign-read-buffer) > 216,220c217,226 > < ;; remove entries that have been fully written > < (setf write-queue (remove-if #'(lambda (x) > < (with-slots (size written) x > < (= size written))) > < write-queue)) > --- > > ;; remove (and dealloc buffers) of entries that have been fully > written > > (let ((unfinished-entries NIL)) > > (setf write-queue > > (nreverse > > (dolist (entry write-queue unfinished-entries) > > (with-slots (size written) entry > > (if (= size written) > > (with-slots (buffer) entry > > (foreign-free buffer)) > > (push entry unfinished-entries))))))) > > _______________________________________________ > nio-devel mailing list > nio-devel at common-lisp.net > http://common-lisp.net/cgi-bin/mailman/listinfo/nio-devel > > >