Theory of the memory effect in thiourea. Defect density waves in modulated systems