In this work we investigate in detail the effects of metal electrodes on the retention performances of HfOx RRAM devices. Motivated by our experimental data, we employ physics-based RRAM modeling and first-principles calculations to show that during the ON-state the concentration of oxygen interstitial (Oi) ions in the oxide depends significantly on the metal electrodes, being much larger for RRAM devices with Pt electrodes compared with Ti. The lower Oi concentration in HfOx with Ti electrodes, known as a strong oxygen getter material, results in improved retention and thermal stability. The presence of oxygen deficient conductive filaments explains the data.