Arduino loosing software

I have an Arduino Decimilia running a little application that runs in communication with my PC via USB. It works perfectly but sometimes it looses the softwre. The PC starts and the progran in arduino does not work. I uploads again the software and it starts working again.

I added a 2 seconds delay when PC starts and the program starts sending data to the Arduino in order to let it to boot.

¿Any ideas of why the software could be lost?

It could be being over written by the bootloader due to stitch on rubbish. Is the arduino connected to your PC while the PC is booting?

Yes, it is connected permanently. But the software that communicates to the Arduino waits 2 seconds before starting to send data.