MariaDB keeps crashing after a few hours with ridiculous memory expectations
You must always use

mysql_free_result( res );
after a query in C after your query has been processed.

https://dev.mysql.com/doc/refman/8.0/en/mysql-free-result.html

This solved my OOM and memory leak from my C daemon, which was the cause of the problem.