Am 2015-04-15 14:28, schrieb Bram Moolenaar:
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.

#v+
debian# zgrep -e 'Kill' syslog*
[..]
syslog.1:Feb 4 21:00:31 debian kernel: [513730.438473] Out of memory: Kill process 12506 (vim) score 731 or sacrifice child syslog.1:Feb 4 21:00:31 debian kernel: [513730.438665] Killed process 12506 (vim) total-vm:2367720kB, anon-rss:1683488kB, file-rss:704kB syslog.1:Feb 4 21:33:57 debian kernel: [515738.409694] Out of memory: Kill process 12980 (vim) score 722 or sacrifice child syslog.1:Feb 4 21:33:57 debian kernel: [515738.409699] Killed process 12980 (vim) total-vm:21474962412kB, anon-rss:1769836kB, file-rss:0kB syslog.1:Feb 5 09:58:12 debian kernel: [525350.540904] Out of memory: Kill process 14446 (vim) score 709 or sacrifice child syslog.1:Feb 5 09:58:12 debian kernel: [525350.540930] Killed process 14446 (vim) total-vm:2291600kB, anon-rss:1592856kB, file-rss:388kB syslog.1:Feb 5 10:40:03 debian kernel: [527863.771911] Out of memory: Kill process 14555 (vim) score 733 or sacrifice child syslog.1:Feb 5 10:40:03 debian kernel: [527863.771916] Killed process 14555 (vim) total-vm:2357740kB, anon-rss:1658984kB, file-rss:720kB syslog.1:Feb 5 11:55:21 debian kernel: [532386.760139] Out of memory: Kill process 15621 (vim) score 711 or sacrifice child syslog.1:Feb 5 11:55:21 debian kernel: [532386.760168] Killed process 15621 (vim) total-vm:21474962356kB, anon-rss:1668904kB, file-rss:0kB syslog.1:Feb 5 16:39:19 debian kernel: [549135.905447] Out of memory: Kill process 17907 (vim) score 914 or sacrifice child syslog.1:Feb 5 16:39:19 debian kernel: [549135.905768] Killed process 17907 (vim) total-vm:2802448kB, anon-rss:1864872kB, file-rss:668kB syslog.1:Feb 6 21:34:40 debian kernel: [579476.006796] Out of memory: Kill process 52709 (vim) score 683 or sacrifice child syslog.1:Feb 6 21:34:40 debian kernel: [579476.006812] Killed process 52709 (vim) total-vm:2214372kB, anon-rss:1796616kB, file-rss:0kB syslog.1:Feb 9 16:39:55 debian kernel: [614689.411146] Out of memory: Kill process 56509 (vim) score 676 or sacrifice child syslog.1:Feb 9 16:39:55 debian kernel: [614689.411181] Killed process 56509 (vim) total-vm:2197600kB, anon-rss:1399052kB, file-rss:0kB
#v-

(this is a virtual machine with 2GB memory).

I have seen Vim run out of memory when working with spell files. That's
why there is incremental compression.

¹) I have an open issue for my csv plugin that makes my vim killed by
the kernel. If I have debugged that correctly, this is caused mainly by memline/memfile.c functions causing a massive allocation of memory on a
:s command. VimL is mostly innocent and calling garbagecollect() does
not help.

That happens when I do something like this in a csv file
(well, 145MB uncompressed file from: http://download.maxmind.com/download/worldcities/):

    :%s/\([^,]*\),/\=printf("%40s,", submatch(1))/g

(e.g. trying to align every cell of a csv file)

Can't we catch the signal and handle it gracefully?

What signal? OOM killer kills usually with -9, I don't think there is any way around it
(and it wouldn't make sense).

Best,
Christian

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