Claimed memory leak in :match

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Claimed memory leak in :match

JohnBeckett
A recent edit to a tip includes a claim that having :match in
autocmd events leads to severe slow downs due to a memory leak.

The tip has a variety of methods to highlight unwanted spaces,
including the following extreme version which attempts to
highlight dubious spaces as you type, but NOT highlight a
trailing space at the end of a line as you are typing it:

highlight ExtraWhitespace ctermbg=red guibg=red
match ExtraWhitespace /\s\+$/
autocmd BufWinEnter * match ExtraWhitespace /\s\+$/
autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
autocmd InsertLeave * match ExtraWhitespace /\s\+$/
autocmd BufWinLeave * call clearmatches()

The last line was just added with the claim that it is necessary
to avoid severe slow downs. I probably won't have an opportunity
to check this claim, and there is no indication of what version
of Vim was used, but I thought I would mention this in case
someone wants to investigate.

The tip is:
http://vim.wikia.com/wiki/Highlight_unwanted_spaces

The difference showing the two recent edits is:
http://vim.wikia.com/index.php?title=Highlight_unwanted_spaces&diff=27609&oldid=27103

John

--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|

Re: Claimed memory leak in :match

Bram Moolenaar

John Beckett wrote:

> A recent edit to a tip includes a claim that having :match in
> autocmd events leads to severe slow downs due to a memory leak.
>
> The tip has a variety of methods to highlight unwanted spaces,
> including the following extreme version which attempts to
> highlight dubious spaces as you type, but NOT highlight a
> trailing space at the end of a line as you are typing it:
>
> highlight ExtraWhitespace ctermbg=red guibg=red
> match ExtraWhitespace /\s\+$/
> autocmd BufWinEnter * match ExtraWhitespace /\s\+$/
> autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
> autocmd InsertLeave * match ExtraWhitespace /\s\+$/
> autocmd BufWinLeave * call clearmatches()
>
> The last line was just added with the claim that it is necessary
> to avoid severe slow downs. I probably won't have an opportunity
> to check this claim, and there is no indication of what version
> of Vim was used, but I thought I would mention this in case
> someone wants to investigate.
>
> The tip is:
> http://vim.wikia.com/wiki/Highlight_unwanted_spaces
>
> The difference showing the two recent edits is:
> http://vim.wikia.com/index.php?title=Highlight_unwanted_spaces&diff=27609&oldid=27103

Well, the best way to find out if it's a leak or not is running Vim
under valgrind.  It will pinpoint the problem quickly.

It's more likely that the look-behind part of the regexp (\@<!) causes
Vim to be very busy.

--
hundred-and-one symptoms of being an internet addict:
179. You wonder why your household garbage can doesn't have an
     "empty recycle bin" button.

 /// Bram Moolenaar -- [hidden email] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\        download, build and distribute -- http://www.A-A-P.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php