For a RPi, it is normal that the memory get full sometimes.
Next time I suggest you to use SSH and check the logs first. A hard full restart is quite problematic, in special for RPi users. You were lucky this time.
Please, before doing something like that read the troubleshooting manual that contain all instructions for cases like these and what to do.