On 15/04/15 14:28, Bram Moolenaar wrote:

Christian Brabandt wrote:

On Di, 14 Apr 2015, Bram Moolenaar wrote:

It's weird to exit when running out of memory, that's not what users
want.  It's easy to accidentally make a Vim script that consumes all
memory.  It's making things easier for developers and worse for users.
Considering there are many more users than developers, that's a bad
choice.

Chances are high, your vim will be killed by the kernels OOM killer if
you ran out of memory, so that does not make any difference in
practice.ยน

The kernel killing a process for OOM?  I have never seen that.  I
believe it can happen in Linux if you use fork() and virtual memory, it
allows a process to run even though the memory isn't actually available.
But Vim doesn't do that.

IIRC this is due to memory "overcommiting" in general and is unrelated to fork() use of the program itself

There are sysctl knobs to tune the behaviour [1], but the default configuration is overcommit enabled. That is one reason why exiting on malloc failure is relatively common (the memory allocations in glib for examples to this as well IIRC, and glib is used by a lot of things these days). The other commonly cited argument is that for any reasonable guarantees every library used must also handle out of memory carefully (for example a Gtk-GVim can still exit randomly on OOM). So most people consider it more worthwhile to keep sudden process death in mind, rather then wasting time on handling malloc returning NULL. I think vim with it's swapfiles is in quite good shape there, at least they saved me a few times already (more from myself than from the OOM-killer though ;))


[1] For example these: https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/vm/overcommit-accounting?id=refs/tags/v4.0

--
--
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

--- You received this message because you are subscribed to the Google Groups "vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui