If the RAM corruption is unrelated to the software actions in your code, the first thing I would suspect is the power supply. If you're powering the board over your PC, maybe the USB port or the cable is the weak spot. Try using something with a lowe...