View Single Post
Old 23 Oct 2021, 01:22 PM   #9
n5bb
Intergalactic Postmaster
 
Join Date: May 2004
Location: Irving, Texas
Posts: 8,750
Quote:
Originally Posted by Bamb0 View Post
What I think is fascinating is how CTRL-Z works!!

Say you have a message your typing and you make 7 changes during writing.....You can press CTRL-Z and it will go back 1 change every press..... How does it do that???

Where is the info stored?? -- Its gotta be LIVE STORED which you have your computer on as that isnt saved???

Very confusing.......
Windows uses "virtual memory". When an application program needs some memory, it makes a request of the operating system. The application is given back a "handle" which can be used to refer to that memory. Windows has a built-in memory manager which works with memory manager hardware in the system processor(s) to manage cache RAM, main memory RAM, and Windows virtual memory hidden files on disk drives.

The chunks of memory which are moved between parts of the system are called "pages", similar to pages in a physical paper book. Imagine a book with 200 pages, but the local physical RAM may only have room for 10 pages. So if you are reading page 55 and you ask for the next page in the file, page 56 can be read into RAM from disk drive. If you next ask for page 113, you will now have pages 55, 56, and 113 in memory. The memory manager remembers which pages are in local RAM, so you can instantly turn to page 55 since it's still in RAM. But after you read a few more pages the pages you haven't used recently won't still be in the limited 10 page memory. If you ask for page 55 at that time, you get a "page fault" and the virtual memory manager has to determine where that page is currently located (in this case, on the disk drive), and recall that page.

Let's say that you are creating a long document in an application (such as Word). When you create the initial empty document, Word makes an operating system request and receives a handle (essentially a hardware memory address) to some memory. In some cases this is a fixed buffer, but often it's a variable length memory buffer which can grow nearly without limit.

At any moment, you might be running 20 different application windows. Each of them has memory allocated via handles. Some of that memory is in the processor system cache, some is in the main RAM, and some is in virtual memory from another source (typically a disk drive). Before you stop an application or turn off your computer, the virtual memory files must be released (thrown away) or written to disk files which will remain long term. Many programs also save one or more backup files which can often be used to recover some or all of the original data if the computer was improperly shut down or the operating system crashes.

The CTRL-Z undo (and CTRL-Y redo) features are built into some (but not all) applications. The undo buffer is typically storing actions as a list of events along with buffers that save data which is needed to undo the action. So if you accidentally delete the wrong paragraph in your document, the undo buffer knows that the previous action was a delete at a certain start and end point in the document, and the old data is saved so it can be recovered. Each application program may do this in a slightly different manner. Since Windows uses virtual memory, there is theoretically no limit to the size of a file (other than the free space available in RAM and the disk drive), but usually applications limit the size of the cut/paste and undo/redo buffers so virtual memory usage doesn't get too large. If programs don't do this efficiently and don't release memory they don't currently need back to the operating system, your computer can get very sluggish and there can be a lot of disk drive activity as data is moved between RAM and the disk drive.

Virtualization (where some subsystem is simulated in a computer using hardware and software) is an important part of modern computing systems. In the case of virtual memory, the system can simulate a 100 GB RAM linearly addressed memory system using 500 MB of RAM and a very large temporary hidden file on the disk drive.

Bill
n5bb is offline   Reply With Quote