After reading about Edit History and Session History and Jean-Luc's post I decided to do an experiment.
1. I reduced the undo steps to 1, and made sure that save edit history was saved.
2. I Chose Primary red (255,0,0) as the Foreground color and Primary Green (0,255,0) as the background color.
3. New document 300 x 125 so wide enough to include full name once saved, and chose the paintbrush tool with size 10 pixels.
4. Left click and drew a red stroke and right click and drew a green stroke.

- 01undo1steps2saveedithistory.jpg (26.57 KiB) Viewed 4011 times
5. I was able to undo the green stroke but not the red stroke. I saved the Session history, As you can see the History palette only shows 1 step.
6. I could not view the Edit History until I saved the image. Then I was able to view and also save the Edit History.
7. I opened the Edit history and the Session (undo) history each in wordpad and compared them.
Note :
1. the disc size of the Edit History (9 KB) was consistently smaller than the Session (Undo) History (16 KB) so long as I kept the image open.
2. even though I did not change the brush except to go to the background color and using the right click draw this was also recorded in the Session history but not in the Edit history.
3. Then I closed the image and then reloaded it and applied a levels command and then saved it .
I saved the session history which only included the Levels command (1 KB) whereas the saved Edit History now had the Levels adjustment added (9 KB).
Conclusions:
The Edit History and Session History are two distinct things that can build up in an open image (s) and so become quite large. The Session History is larger than the Edit History for a starting image.
Saving the image regularly loses the Session history if the image is closed and reloaded but the Edit history continues increasing in size.
Changing the preferences to stop the Edit History being saved will save some space / memory.
Reducing the number of Undo steps will save much more memory for a continuously open image.
Systems available Win7, Win 8.1,Win 10 Version 1607 Build 14393.2007 & version 20H2 Build 19042.867