Wednesday, July 6, 2022

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

On 2022-07-06 11:00, Bram Moolenaar wrote:
> 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).

I believe the setting is controlled by the vm.overcommit_memory
sysctl value. Setting it to 2 instructs the kernel to never
overcommit, letting vim die when it tries to grab more RAM than
available.

https://www.kernel.org/doc/Documentation/vm/overcommit-accounting

Also, if the file is that large and if the :s// isn't overly complex
(e.g. using sub-replace-\= or other vim-specific functionality), it
might be less stressful on the system to use sed(1) instead

sed 's/old/new/g' input.log > output.log

which should run in a fairly fixed amount of RAM.

-Tim


--
--
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/20220706073533.023012e3%40bigbox.attlocal.net.

No comments: