Memory effects and peak effect in type II superconductors