When I'm just chilling on the desktop or doing whatever, Ubuntu 14.04 LTS will (every 10-20 minutes or so) just randomly freeze. The screen just stops, I can't see my mouse move, etc. However, I can Alt+Ctrl+F1 into a tty terminal (though it's not much use).
However, I noticed that if I close my laptop's lid, re-open it, then enter my password to unlock the lock screen, everything is fine.
What is going on here? How can I fix / stop / prevent this?
Note: My laptop has an nvidia-optimus setup, but Ubuntu 14.04 LTS automatically recognized it and had the nvidia drivers applied.