As shown in FIG. 6F, a passivation layer 38 can be optionally formed. In some embodiments, the passivation layer 36 is insulative. In some embodiments, the passivation layer 38 covers the upper surface of the top electrode 22. In some embodiments, the passivation layer 38 covers edges of the top electrode 22, the capping layer 20 and the ion reservoir region 18. In some embodiments, the passivation layer 38 further covers a portion of the switching layer 16. In some embodiments, the material of the passivation layer 38 includes dielectric material such as silicon oxide, silicon nitride, silicon oxynitride or the like, but is not limited thereto.