Memory effects and glassy behavior have been repeatedly observed in disordered nematic liquid crystals but the connection between these effects and the system topology remained unrevealed. We present an analysis of the local and global topology of the nematic ordering in the presence of quenched disorder and we show that nematics with quenched disorder can be mapped into a system of pinned defect lines and that the memory of the system stems from the pinning of these strings.