5 The Linux kernel supports the following overcommit handling modes
8 Heuristic overcommit handling. Obvious overcommits of address
9 space are refused. Used for a typical system. It ensures a
10 seriously wild allocation fails while allowing overcommit to
11 reduce swap usage. root is allowed to allocate slightly more
12 memory in this mode. This is the default.
15 Always overcommit. Appropriate for some scientific
16 applications. Classic example is code using sparse arrays and
17 just relying on the virtual memory consisting almost entirely
21 Don't overcommit. The total address space commit for the
22 system is not permitted to exceed swap + a configurable amount
23 (default is 50%) of physical RAM. Depending on the amount you
24 use, in most situations this means a process will not be
25 killed while accessing pages but will receive errors on memory
26 allocation as appropriate.
28 Useful for applications that want to guarantee their memory
29 allocations will be available in the future without having to
30 initialize every page.
32 The overcommit policy is set via the sysctl ``vm.overcommit_memory``.
34 The overcommit amount can be set via ``vm.overcommit_ratio`` (percentage)
35 or ``vm.overcommit_kbytes`` (absolute value). These only have an effect
36 when ``vm.overcommit_memory`` is set to 2.
38 The current overcommit limit and amount committed are viewable in
39 ``/proc/meminfo`` as CommitLimit and Committed_AS respectively.
44 The C language stack growth does an implicit mremap. If you want absolute
45 guarantees and run close to the edge you MUST mmap your stack for the
46 largest size you think you will need. For typical stack usage this does
47 not matter much but it's a corner case if you really really care
49 In mode 2 the MAP_NORESERVE flag is ignored.
55 The overcommit is based on the following rules
58 | SHARED or READ-only - 0 cost (the file is the map not swap)
59 | PRIVATE WRITABLE - size of mapping per instance
61 For an anonymous or ``/dev/zero`` map
62 | SHARED - size of mapping
63 | PRIVATE READ-only - 0 cost (but of little use)
64 | PRIVATE WRITABLE - size of mapping per instance
67 | Pages made writable copies by mmap
68 | shmfs memory drawn from the same pool
73 * We account mmap memory mappings
74 * We account mprotect changes in commit
75 * We account mremap changes in size
78 * We report the commit status in /proc
79 * Account and check on fork
80 * Review stack handling/building on exec
82 * Implement actual limit enforcement
86 * Account ptrace pages (this is hard)