The Memento pattern is used to save and restore the internal state of an object without exposing its implementation details, preserving encapsulation.
The Memento pattern involves the Originator (creates and restores state), the Memento (stores state), and the Caretaker (manages mementos).
Using incremental snapshots or storing only the differences (deltas) between states reduces memory usage and improves scalability.
The Memento pattern can consume significant memory because it stores copies of object states, especially if many states are saved.
The Caretaker asks the Originator for a memento, the Originator creates it, the Caretaker stores it, and later the Originator restores state from it.
