frequent out of sync error messages

I have been using Arduino Uno R3 boards for a couple of years now and I have ongoing problems with out of sync error messages when I upload sketches (I run the IDE on an old XP machine as well as Windows 10). This happens even when the COM port is correct. I try recompiling, unplugging the USB cable and plugging it back in, uploading again, deselecting the COM port and reselecting the right port... Eventually the sketch will upload but I haven't found any way to get rid of this problem. Can you tell me what's going on?