Hi forum,

I have had trouble with memory management on linux in when memory use nears ram limit& upon searching, I found a program called nohang that can help. if you have any other suggestions of a useful program please share.

Now, I'm looking for opinions on what to include in converting the systemd service file to 66-tools front end service file.

systemd file:
[Unit]
Description=Sophisticated low memory handler
Documentation=man:nohang(8) https://github.com/hakavlad/nohang
Conflicts=nohang-desktop.service
After=sysinit.target

[Service]
ExecStart=/usr/bin/nohang --monitor --config /etc/nohang/nohang.conf
SyslogIdentifier=nohang
KillMode=mixed
Restart=always
RestartSec=0

CPUSchedulingResetOnFork=true
RestrictRealtime=yes

TasksMax=25
MemoryMax=100M
MemorySwapMax=100M

UMask=0027
ProtectSystem=strict
ReadWritePaths=/var/log
InaccessiblePaths=/home /root
ProtectKernelTunables=true
ProtectKernelModules=true
ProtectControlGroups=true
ProtectHostname=true
MemoryDenyWriteExecute=yes
RestrictNamespaces=yes
LockPersonality=yes
PrivateTmp=true
DeviceAllow=/dev/kmsg rw
DevicePolicy=closed

# Capabilities whitelist:
# CAP_KILL is required to send signals
# CAP_IPC_LOCK  is required to mlockall()
# CAP_SYS_PTRACE is required to check /proc/[pid]/exe realpathes
# CAP_DAC_READ_SEARCH is required to read /proc/[pid]/environ files
# CAP_DAC_OVERRIDE fixes # 94
# CAP_DAC_READ_SEARCH CAP_AUDIT_WRITE CAP_SETUID CAP_SETGID CAP_SYS_RESOURCE
#   are required to send GUI notifications
# CAP_SYSLOG is required to check /dev/kmsg for OOM events

CapabilityBoundingSet=CAP_KILL CAP_IPC_LOCK CAP_SYS_PTRACE \
CAP_DAC_READ_SEARCH CAP_DAC_OVERRIDE CAP_AUDIT_WRITE CAP_SETUID CAP_SETGID \
CAP_SYS_RESOURCE CAP_SYSLOG

# `PrivateNetwork=true` breaks GUI notifications on oldstable distros
# (Debian 8, CentOS 7, Linux Mint 18). On modern distros you can set
# PrivateNetwork=true for security reasons.
# PrivateNetwork=true

# Set realtime CPU scheduling policy if you want
# CPUSchedulingPolicy=rr
# CPUSchedulingPriority=1

[Install]
WantedBy=multi-user.target
attempted conversion to 66:
[main]
@ type = longrun
@ version = 0.1.0
@ description = "Sophisticated low memory handler"
@ user = ( root )
@ options = ( log env )

[start]
@ execute = ( /usr/bin/nohang --monitor --config /etc/nohang/nohang.conf )

[environment]
conf_file=! /etc/nohang/nohang.conf
Do you have a swap partition or swap file? If you do, how much is your ram and what size is your swap?

If not, this is the first thing to do, an immediate improvement.
My ram is 8gb, upgraded from 4gb where I had more problems. No swap however, thanks for the suggestion. I will make a 2gb swap partition if I keep having problems.
From what I've read there are files that are in ram that don't change much during the entire session of the system, while others change all the time. Linux is smart enough to move those non-changing files into swap leaving ram for fast changes. There is also journaling information for the file system written in swap that when you use recover=uuid.... in the bootloader it minimizes the risk of data corruption during a sudden power failure. On reboot the system finds the information that it needs to rebuild filesystems that weren't unmounted correctly. To me this is convincing to have even if you have 64GB ram
this is really a complex one. For the moment (i said for the moment ;)) capability and namespace are not available, so basically your service should work. But you made a mistake at the [environment] section
[main]
@ type = longrun
@ version = 0.1.0
@ description = "Sophisticated low memory handler"
@ user = ( root )
@ options = ( log env )

[start]
@ execute = ( /usr/bin/nohang --monitor --config ${conf_file} )

[environment]
conf_file=!/etc/nohang/nohang.conf 
You added a space but the "!" and the name of the directory. So, you can do stuff like this:
conf_file = !/etc/nohang/nohang.conf
conf_file= !/etc/nohang/nohang.conf
but you cannot do:
conf_file = ! /etc/nohang/nohang.conf 
conf_file= ! /etc/nohang/nohang.conf 
Also, i rectified your @ execute field to handle your variable conf_file set at your [environment] section. Now you don't need anymore to touch your frontend file to change the configuration file to use. Simply edit the configuration file with the 66-env program to change the path of the configuration file to use, than restart the service:
# 66-env nohang
# 66-start -r nohang
Very helpful Eric, Thanks! looking forward to what is in store : )

Powered by Obarun