From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28431 invoked from network); 14 Feb 2008 15:10:47 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.4 (2008-01-01) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.4 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 14 Feb 2008 15:10:47 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 37621 invoked from network); 14 Feb 2008 15:10:40 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 14 Feb 2008 15:10:40 -0000 Received: (qmail 11418 invoked by alias); 14 Feb 2008 15:10:36 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 24551 Received: (qmail 11399 invoked from network); 14 Feb 2008 15:10:35 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 14 Feb 2008 15:10:35 -0000 Received: from cluster-d.mailcontrol.com (cluster-d.mailcontrol.com [217.69.20.190]) by bifrost.dotsrc.org (Postfix) with ESMTP id A048680482A1 for ; Thu, 14 Feb 2008 16:10:27 +0100 (CET) Received: from rly06d.srv.mailcontrol.com (localhost.localdomain [127.0.0.1]) by rly06d.srv.mailcontrol.com (MailControl) with ESMTP id m1EFARn0014025 for ; Thu, 14 Feb 2008 15:10:27 GMT Received: from submission.mailcontrol.com (submission.mailcontrol.com [86.111.216.190]) by rly06d.srv.mailcontrol.com (MailControl) id m1EFA2V9013195 for zsh-workers@sunsite.dk; Thu, 14 Feb 2008 15:10:02 GMT Received: from cameurexb01.EUROPE.ROOT.PRI ([62.189.241.200]) by rly06d-eth0.srv.mailcontrol.com (envelope-sender Peter.Stephenson@csr.com) (MIMEDefang) with ESMTP id m1EF9xUj012640; Thu, 14 Feb 2008 15:10:02 +0000 (GMT) Received: from news01.csr.com ([10.103.143.38]) by cameurexb01.EUROPE.ROOT.PRI with Microsoft SMTPSVC(6.0.3790.3959); Thu, 14 Feb 2008 15:09:58 +0000 Received: from news01.csr.com (localhost.localdomain [127.0.0.1]) by news01.csr.com (8.14.2/8.13.4) with ESMTP id m1EF9ww7019321; Thu, 14 Feb 2008 15:09:58 GMT Received: from csr.com (pws@localhost) by news01.csr.com (8.14.2/8.14.2/Submit) with ESMTP id m1EF9wdm019318; Thu, 14 Feb 2008 15:09:58 GMT Message-Id: <200802141509.m1EF9wdm019318@news01.csr.com> X-Authentication-Warning: news01.csr.com: pws owned process doing -bs To: zsh-workers@sunsite.dk (Zsh hackers list), "Anonymous bin ich" Subject: Re: Problem with menu-completion In-reply-to: <82839db60801291122n6db4ae54r2218310f2244ed5f@mail.gmail.com> References: <82839db60801291122n6db4ae54r2218310f2244ed5f@mail.gmail.com> Comments: In-reply-to "Anonymous bin ich" message dated "Tue, 29 Jan 2008 20:22:19 +0100." Date: Thu, 14 Feb 2008 15:09:58 +0000 From: Peter Stephenson X-OriginalArrivalTime: 14 Feb 2008 15:09:58.0930 (UTC) FILETIME=[AA234F20:01C86F1B] X-Scanned-By: MailControl A-08-00-01 (www.mailcontrol.com) on 10.68.1.116 X-Virus-Scanned: ClamAV 0.91.2/5809/Thu Feb 14 11:52:07 2008 on bifrost X-Virus-Status: Clean "Anonymous bin ich" wrote: > 1. Type any command which will have multiple completion choices. Press > TAB for scrolling through them. (ex, for fvwm, type "fvw" and then > press tab) > 2. Keep scrolling. To increase the speed, you may want to never leave > the TAB key. > 3. The speed of scrolling steadily decreases, while CPU usage steadily > increases. > > 4. Now delete everything from the command line, and type "xr" (for > another completion list), and press TAB. > 5. The problem still exists. > 6. Delete everything and press enter (or press ^C) for another prompt. > 7. The problem disappears. As I guessed, the problem is the use of heap memory. Here's a partial fix: the heap is now freed after every completed editor command. This should work OK since individual editor commands are expected to be self-contained (if it's not OK, something is making icky assumptions). This removes the memory still present at step 5., although actually it'll happen as soon as you stop the menu selection. It should be possible to fiddle with menu selection (the big for-loop in domenuselect() in complist.c) such that it doesn't accumulate heap memory over iterations and so it can be freed in the same way, so that you don't pick it up when scrolling. However, that'll take a little more thought (I hope not too much more). (All but the middle two hunks here are cosmetic.) Index: Src/Zle/compresult.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/Zle/compresult.c,v retrieving revision 1.72 diff -u -r1.72 compresult.c --- Src/Zle/compresult.c 22 Aug 2007 17:24:10 -0000 1.72 +++ Src/Zle/compresult.c 14 Feb 2008 15:03:15 -0000 @@ -1200,6 +1200,7 @@ showinglist = -2; return; } + /* Otherwise go to the next match in the array... */ do { if (!*++(minfo.cur)) { Index: Src/Zle/zle_main.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_main.c,v retrieving revision 1.102 diff -u -r1.102 zle_main.c --- Src/Zle/zle_main.c 18 Dec 2007 10:42:37 -0000 1.102 +++ Src/Zle/zle_main.c 14 Feb 2008 15:03:16 -0000 @@ -1000,6 +1000,8 @@ FD_ZERO(&foofd); #endif + pushheap(); + /* * A widget function may decide to exit the shell. * We never exit directly from functions, to allow @@ -1070,7 +1072,11 @@ #endif if (!kungetct) zrefresh(); + + freeheap(); } + + popheap(); } /* Read a line. It is returned metafied. */ @@ -1786,12 +1792,19 @@ /**/ mod_export struct hookdef zlehooks[] = { + /* LISTMATCHESHOOK */ HOOKDEF("list_matches", NULL, 0), + /* COMPLETEHOOK */ HOOKDEF("complete", NULL, 0), + /* BEFORECOMPLETEHOOK */ HOOKDEF("before_complete", NULL, 0), + /* AFTERCOMPLETEHOOK */ HOOKDEF("after_complete", NULL, 0), + /* ACCEPTCOMPHOOK */ HOOKDEF("accept_completion", NULL, 0), + /* REVERSEMENUHOOK */ HOOKDEF("reverse_menu", NULL, 0), + /* INVALIDATELISTHOOK */ HOOKDEF("invalidate_list", NULL, 0), }; -- Peter Stephenson Software Engineer CSR PLC, Churchill House, Cambridge Business Park, Cowley Road Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070