Overcoming challenges associated with implementation of resistive random access memory technology for non-volatile information storage requires identifying the material characteristics responsible for resistive switching. In order to connect the switching phenomenon to the nano-scale morphological features of the dielectrics employed in memory cells, we applied the enhanced conductive atomic force microscopy technique for in situ analysis of the simultaneously collected electrical and topographical data on HfO2 stacks of various degrees of crystallinity. We demonstrate that the resistive switching is a local phenomenon associated with the formation of a conductive filament with a sufficiently small cross-section, which is determined by the maximum passing current. Switchable filament is found to be formed at the dielectric sites where the forming voltages were sufficiently small, which, in the case of the stoichiometric HfO2, is observed exclusively at the grain boundary regions representing low resistant conductive paths through the dielectric film.