2026-11-30 20:38

Status: Complete


Fix Out of Memory issues

Recently the proxmox host has been crashing the server because the memory would cake up. Originally the 101 MidasCloud qm was allocated about 18 gb of memory as I thought the lack of the memory was the issue.

This would kill the qm however as it would keep filling out and the OOM caused the process to be shutdown. The reason for this was because the kernel would actually cache data from the disk in RAM, and since Jellyfin reads from the disk a lot (about 210 gb according to block I/O), it filled the cache. This caused the memory to bloat, and the proxmox host cannot distinguish this from valid memory, and so it would stay there everytime a library scan was rerun or something.

Memory was checked with the following commands

free -h
docker stats --no-stream

This was run on the 101 VM, and it showed all in all the docker containers took up about 2 GB of ram under load, and so the issue was the cache taking up ram that the host could not free. This was then fixed by adding in a swap file for the host itself so it could better manage the memory, and also decreasing the size of the memory the QM took up, allowing for more memory safety during spikes, and letting ballooning reclaim better memory:

run on proxmox:

fallocate -l 8G /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
echo '/swapfile none swap sw 0 0' >> /etc/fstab
echo 'vm.swappiness=10' > /etc/sysctl.d/99-swappiness.conf
sysctl --system

This then applied the new swap over to the root machine, and this was confirmed after a full restart of the server itself with with:

root@pve:~# free -h
               total        used        free      shared  buff/cache   available
Mem:            23Gi       1.5Gi        21Gi        46Mi       344Mi        21Gi
Swap:          8.0Gi          0B       8.0Gi
root@pve:~# 

From there I changed the memory of the 101 qm to be smaller, allowing for still good workload balance, but less memory to be taken up by the VM, letting it be used for other things in the future:

root@pve:~# qm set 101 --memory 8192 --balloon 4096

For clearing the buffer on say a large media update to jelly fin, run

sync

first just to be safe and make sure no data is lost, a bit redundant but easy enough, and then run the following to store all of the cache/buff memory held onto jellyfin

sync && echo 3 | sudo tee /proc/sys/vm/drop_caches

References