Combining scanning electron microscopy (SEM) and electron-beam-induced current (EBIC) imaging with transport measurements, it is shown that the current flowing across a two-terminal oxide-based capacitor-like structure is preferentially confined in areas localized at defects. As the thin-film device switches between two different resistance states, the distribution and intensity of the current paths, appearing as bright spots, change. This implies that switching and memory effects are mainly determined by the conducting properties along such paths. A model based on the storage and release of charge carriers within the insulator seems adequate to explain the observed memory effect. 61.16.Bg, 72.20.Jv, 73.40.Rw