Hi,
Investigating crashes and freezes, etc, can be very difficult.
When everything is running fine and you collect data, you will see that everything is more or less okay.
When it crashed or is frozen, you are too late.
Since a few weeks I had the problem that my MM was frozen and I could not enter any commands or a command took painstakingly long to return output.
A command like top was out of the question for example.
Using a script running as a cron job, I was able to identify a memory issue with electron.js.
I then decide to use a usb stick on which I created a swap device.
Since then my MM is not freezing anymore.
And I am able to see electron.js using up my memory and sometimes I see spikes in CPU usage.
Mind you, that crashing is something different then freezing, but the tools to use are more or less the same, provided the MM application or a MM module is not the culprit.
My script to check memory usage, very basic and simple:
pi@MagicPi:~ $ cat top.sh
#!/bin/sh
date >> /home/pi/top.txt
top -b -o +%MEM | head -n 22 >> /home/pi/top.txt
echo "=============================================" >> /home/pi/top.txt
The cron job:
00,05,10,15,20,25,30,35,40,45,50,55 * * * * /home/pi/top.sh >/dev/null 2>&1
%CPU will sort on CPU usage.
Concerning swap space, top will show the usage, but this gives a quick view:
$ free -h
Swap details via:
$ swapon -s
There are many more commands and settings to look at, but one has to start somewhere :-)
Good luck.