If I got it correctly this would overwrite the previous memory reading for that line when entering a loop. This does not seem fair to me. I agree however that storing all readings is a waste of space, but what about just storing the max?  Something like 

    self.code_map[frame.f_code][self.prevline] = max(mem, previous_reading)

?