Irregularly, when I am using a program that displays text (gedit, neovim, firefox, etc.) the operating system will freeze for a few seconds. When the operating system unfreezes, the operating system selects about a paragraph of text either above or below the current cursor location. The text selection happens even if I am not trying to select text when the operating system freezes.
It currently happens the most when I am just scrolling up and down through a long file (nothing else pressed).
I'm running Ubuntu 17.04 in the VirtualBox 5.1.22. The system comes with two graphics cards: the default intel driver and an NVIDIA® GeForce® GTX 960M.
Any help on how to debug this problem would be appreciated. I don't know where to start. I'm happy to provide any information that may help.