HA frequent restarts / Lost counter clicks

Hi there!
Running HA on a Synology NAS 918+ in VMM. So far, so good.
I integrated a gas consumption counter through a reed contact on my gas meter.
So whenever the wheel of the mechanical counter flies by, it triggers a signal.
That is covered by an automation which increases a counter helper by 1.
Works like a charm, basically.

Looking at the data though, I found out the hard way that my instance seems to reboot/restart
every 20 mins or so! And although I had set the helper to restore the last known value upon restart,
I get these peaks/hickups in the trend, which suggest that it does NOT return the last known one but a somewhat older one.

So two things - why would my HA restart every 20 mins in the first place (I got it improved to 1/hr by increasing the memory of the VMM to 2 GB)? And - even if it did, why does it not keep the highest reading that it once had (i.e. right before the restart)?

Thanks for your insight!!!

It is typical for systems to collect a bit a data over a short timespan and then commit it in one go.
Doing the writing right away would increase the resource usage a lot to handle the storage operations and it would also wear down the storage medium faster, especially for SDcard storages.
On a normal running system the commit of changes will happen automatically when the system is shutting down, but since you are probably experiencing unhandled errors that cause a sudden reboot, then there is no logic that can catch the events and commit the changes.