Solid-state structural transformation coupled with an electronic property change is an important mechanism for nonvolatile information storage technologies, such as phase-change memories. Here we exploit phase-change GeTe single-nanowire devices combined with ex situ and in situ transmission electron microscopy to correlate directly nanoscale structural transformations with electrical switching and discover surprising results. Instead of crystalline-amorphous transformation, the dominant switching mechanism during multiple cycling appears to be the opening and closing of voids in the nanowires due to material migration, which offers a new mechanism for memory. During switching, composition change and the formation of banded structural defects are observed in addition to the expected crystal-amorphous transformation. Our method and results are important to phase-change memories specifically, but also to any device whose operation relies on a small scale structural transformation.