Circuit:
Peak Detector-1.png

Any time , the diode conducts. When , the diode is off. stays constant. Basically, will stay at the highest value that it’s seen until it sees a higher value.

Peak Detector.png

We can reset it by adding a switch:
Peak Detector-2.png

There will be some leakage, so it won’t hold the value perfectly:
Peak Detector-3.png