2 ms·
This has little to to do with C language. Every programming language that allocates dynamic memory from the operating system via syscall has to deal with it. I
by nabla9 5y ago
This has little to to do with C language. Every programming language that allocates dynamic memory from the operating system via syscall has to deal with it.
In Linux you can use sysctl ´vm.overcommit_memory´ to make the OS do what you want. There are three options:
0 = The default is heuristic overcommit handling.
1 = Always overcommit. Good choice for many data heavy science applications that use gigantic sparse arrays.
2 = No overcommit. Only swap + tunable amount (default is 50%) of physical RAM available. Then allocation fails.