Wednesday, July 6, 2022

Re: How to limit amount of memory used by vim?

> using Vim 7.4 on Linux server I have opened large log file and I tried to
> perform some log formatting using ":%s" command.
>
> It looks like Vim froze (probably it didn't, it just worked hard), but like
> after a minute Linux server got out of memory and Linux start killing the
> biggest memory consumption processes including one very important server.
> >From Linux logs I see vim consumed 50 GB of memory, that is what triggered
> Linux to get out of memory.
>
> Just wondering is there a way to set in Vim, how much memory is Vim allowed
> to use? If Vim exceeds that amount the last action performing is just
> canceled with error.

With a ":%s" command all lines are saved in memory for undo. Vim may
at some point fail to allocate memory and then stop with an error
message. However, because of the way Linux manages memory it will
happily give more memory to Vim than it actually has. There is a system
setting to change that behavior. I recall a lively discussion between
Linux and BSD users about this stragety (BSD works just fine, Linux can
freeze).

In Vim you can disable undo:

setlocal ul=-1


--
"I don't know how to make a screenshot" - Richard Stallman, July 2002
(when asked to send a screenshot of his desktop for unix.se)

/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

--
--
You received this message from the "vim_use" 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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20220706100034.4A4481C1342%40moolenaar.net.

No comments: