# OOM killer like configuration?



## fluca1978 (Mar 25, 2021)

Hi all,
I'm not able to find out if FreeBSD has something like the Linux OOM Killer, and in the case, what is the behavior and the settings. Anyone can please point me in the right direction?


----------



## balanga (Mar 25, 2021)

OOM Killer? Whatthefoxthat?


----------



## mtu (Mar 25, 2021)

See here, especially the subsection titled "*Why is the kernel killing my processes?*":








						Exploring Swap on FreeBSD
					

Answer burning FreeBSD memory questions like when to use swap space and how, but also kernel reactions to the shortages of free memory. Check out our 2021 guide to using swap space in FreeBSD.




					klarasystems.com


----------



## fluca1978 (Apr 1, 2021)

mtu said:


> See here, especially the subsection titled "*Why is the kernel killing my processes?*":
> 
> 
> 
> ...


Very interesting, thanks.
One question: how I can get information about a running process that has been `protect`ed?
I mean, I cannot find any flag in `ps`, any other tool?

*edit:* even `procstat` within the memory section does show different flags with or without `protect` in place, at least I'm not able to see the differences.


----------



## mtu (Apr 1, 2021)

fluca1978 said:


> One question: how I can get information about a running process that has been `protect`ed?
> I mean, I cannot find any flag in `ps`, any other tool?



ps(1) can show you all sorts of "flags" associated with a process. From the manpage:



> *flags*    The flags associated with the process as in the include file <sys/proc.h>:
> […]
> P_PROTECTED                0x100000    Do not kill on memory overcommit
> P_SIGEVENT                   0x200000    Process pending signals changed
> ...




When you run `ps ux -o flags`, you'll see those flags at the end of each line. If I'm reading the manpage correctly, then a process is protected when a 1 (or any odd number?) appears as the _third_ digit from the left in that column.

On a server of mine, that gives me `syslog`, `sshd` and `cron` as protected (and nothing else), which makes sense (emphasis mine):



> root   406   0.0  0.0  12556   3664  -  Is   Tue19       0:00.02 /usr/sbin/mountd 10000000
> root   497   0.0  0.0   6416   1636  -  Ss   18Mar21     0:22.97 */usr/sbin/syslog 10100000*
> root   620   0.0  0.0   6372   1072  -  Ss   18Mar21     3:51.92 /usr/sbin/powerd 10000000
> root   672   0.0  0.0  12856   2396  -  Ss   18Mar21     0:00.33 */usr/sbin/sshd   10100100*
> ...


----------



## Mjölnir (Apr 1, 2021)

You may want to consider to subscribe to (and/or read the archive of) the <freebsd-hackers> mailing list.  IIUC s/o is currently working on that to improve the OOM-killer.


----------

