• Welcome to ForumKorner!
    Join today and become a part of the community.

[Tutorial] Logical Memory Guide

chinzka

Member
Reputation
0
Logical Memory Guide
How a PC's memory is "put together" ... by Tom S. Bair Jr.

Logical memory is the way your computer's physical memory (its RAM) is "put together" for your operating system. Physical memory must be organized in a logical manner for your computer to use it. To better understand this concept, let's discuss a map that explains how memory is laid out.

By The Numbers
In order for us to be on the same page when it comes to understanding terms like "kilobytes" and "megabytes" in the discussion that follows, let's do a bit of review:


Bit = 0 or 1 (translates as either "off" or "on" to a PC)

Byte = 8 bits

Kilobyte (K) = 1,024 bytes

Megabyte (MB) = 1,048,576 bytes or 1,024KB

Gigabyte (GB) = 1,073,741,824 bytes or 1,024MB
Digital Counting
Because digital information is all based on just two numbers (0 and 1), it's usually more convenient and accurate to use a base-2 numbering system for counting bits than the base-10 numbers we use in everyday life. Here's how to count to eight in base-2 (starting at zero): 0, 1, 10, 11, 100, 101, 110, 111, 1000.

Since this sort of counting quickly results in very long numbers, computer professionals use a base-16 (24) system called "hexadecimal" that adds the letters A to F after the digit 9. Here's how to count to 16 in hexidecimal (again, starting at zero): 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F, 10.

MS-DOS Memory Map
The MS-DOS memory map covers the first 1 MB, or 1024K, of memory. This map is also referred to as a stack, because the memory blocks are best described as being "stacked" on top of one another.

The DOS memory map is divided up into sixteen blocks, each containing 64K of memory. These sixteen blocks are further divided into four 16K "pages." Dividing memory this way allows us to look in a more detailed manner at how an application is using memory.

When you need to refer to these blocks, you can do so by their block number (block 1, block 2, and so forth), or, more commonly, as a range of hexadecimal addresses. Memory blocks are typically five-digit hex addresses, primarily because the largest number in the range is five digits (FFFFF=1,048,575 decimal, which is 1 MB).

Conventional Memory
The first 640 KB in the memory map is conventional memory. It occupies the first ten blocks (00000 to 9FFFF). This memory is used by your computer to not only load the operating system, files, and device drivers, but also to run your programs.

The first of these ten blocks is used for loading DOS and Windows operating system files into memory. Keep in mind that this block is only 64 KB in size. This area is also used to load any memory drivers (EMM386.EXE and HIMEM.SYS) along with input/output buffers and interrupt processors. A very busy block, indeed.

All of these programs will want to take up more memory than is available, so developers came up with yet more types of memory.

Reserved Memory
Some RAM is reserved for use by devices in the computer to store data so that it can be accessed directly by the CPU. This area of RAM, called "Upper Memory," is composed of the remaining six blocks -- the upper 384 KB -- in the memory map.

The first two of these six blocks of reserved memory are used for accessing video RAM. When your computer needs to send information to your display, it writes it to this two-block location. Your video adapter has its own memory mapped into this area.

This area is only 128 K in size, yet video cards have from 1 MB up to 4 MB or more on them. So now you are asking, "How can the computer fit 1 to 4 MB into a 128 KB area?"

The answer is in a technique known as paging. Paging works by taking a portion of that 1 to 4 MB memory and accessing it by swapping it into this reserved area as data needs to be written to it.

The problem with paging is that it's very inefficient. Imagine you're at a library doing research that involves lots of books. The most efficient way to work would be to have a big table all to yourself where you could have all the books open to the relevant pages. A paging system would be analogous to being able to work with only one book at a time: whenever you needed a different one, you'd have to return the first book to the counter and check it in before you could check out another one.

The last four blocks of reserved memory are used by other adapter cards (such as sound cards, LAN network cards, etc.), and for mapping the BIOS ROM information.

Expanded Memory
The Expanded Memory System (EMS) was developed by Lotus, Intel, and Microsoft to circumvent the 640K conventional memory barrier. EMS works by using the same type of paging technology used by video cards. Expanded memory is divided into 16 KB pages that are swapped four pages at a time into a special memory address space in reserved memory. The area in reserved memory that holds these pages is called the expanded memory page frame. This area usually occupies a full 64K block in the memory map and is created when EMM386.EXE, the expanded memory driver, is loaded.

Although very few programs use EMS today, it is handy to load DOS drivers and TSR (Terminate and Stay Resident) programs into the unused portions of reserved memory. You do this by adding the below two lines to your CONFIG.SYS file:

DEVICE=C:\WINDOWS\EMM386.EXE
DOS=UMB

Using EMS has the benefit of freeing up conventional memory for use by your programs and is a key concept to memory optimization in DOS. If you don't need expanded memory capability, you can add NOEMS at the end of the line that loads EMM386.EXE. This will turn off EMS, yet allow the ability to load drivers and TSRs into upper memory blocks (a.k.a. UMB).

Extended Memory
EMS was great in the early days of DOS. It allowed people to add a megabyte or two of extra memory to deal with those burgeoning 1-2-3 spreadsheets. Unfortunately, as explained above, paging methods are pretty inefficient. The computer would be much better off if it were able to work with all of its memory at one time. Enter extended memory.

With extended memory, the CPU uses two different operating modes: real mode and protected mode. In real mode, your computer would operate like an old 8086 (only faster) and is able to access only 1 MB of RAM. To access memory above 1 MB, the CPU switches to protected mode. Most programs written for Windows 95, 98, XP, NT and Windows 2000 are able to take advantage of the benefits of extended memory in protected mode.

Killing a Myth
There is a persistent myth going around that Windows 95 can recognize only 64 MB of RAM. If you add memory beyond the 64 MB limit, the myth goes, you will slow down its performance. To compound the myth, it is now stated that Windows 98 or NT cures this problem.

There is actually a 64MB limit, but it has nothing to do with Windows 95 or, for that matter, any other operating system. Windows 95 is able to access up to 2 GB of RAM.

Computers with a Pentium CPU and one of two Intel chipsets, the 430TX and 430VX, often include slots for as much as 256 MB of memory. However, the Level 2 cache on systems built with these chipsets will ignore all but the first 64 MB of RAM. The problem has nothing to do with Windows 95; it doesn't matter what operating system you use. Adding RAM beyond the 64 MB barrier will slow down the system due to the cache not being able to handle the extra RAM correctly. The good news is that even uncached RAM is faster than the alternative of using virtual memory on the hard drive.

If you have a Pentium II system, then you need not worry at all. This system uses the 440LX, 440FX, or 440BX chipset, which can cache the entire amount of installed system RAM. Older Pentium systems which were built around the 430HX chipset are able to cache up to 512 MB of system RAM.

Your Memory Layout
If you are running Windows 95 or 98, you can discover your memory layout by rebooting to DOS and running the mem command. To do this, select Start | Shut Down | Restart in MS-DOS Mode. Once you're at the command prompt, type mem.

You'll be able to see all sorts of information about your memory:


The types of memory and total amount of memory in your computer.

The amount of memory of each type that is used and free.

The amount of conventional and upper memory that is free.

Whether DOS is resident (loaded) in the high memory area.
If you are running Windows NT, then press Ctrl + Shift + Esc. This will pop up the NT Task Manager, which will display every running program and process. You can also launch the Task Manager by right-clicking on an empty spot on your taskbar and then choosing "Task Manager ..." from the popup menu.

Click on the Performance tab to get a look at a host of system information:


CPU Usage and CPU Usage History.

Memory Usage and Usage History.

Totals for Handles, Threads, and Processes.

Your total Physical Memory, how much is available, and your file cache size.

Your total Commit Charge, limit, and peak.

Total Kernel memory, the paged and nonpaged amounts.
Out of Memory
You should now have a better understanding of logical memory. Home users of Windows 95 or 98 should have between 64MB and 512MB of RAM installed in their computers for best performance. You should have no less than 128MB of RAM if you are running Windows XP. With the low cost of memory DIMMs today, it is not uncommon to see PCs with 1024MB (1 GB) of system memory.


Source: http://www.security-forums.com/viewtopic.php?t=1036
 

Duckinator

Member
Reputation
0
there is a lot of good advice here and it help me and my computer out because we both have memory problems. :)
 

peelsaven

Member
Reputation
0
wow this is a long thread thank you for all the information provided I will subscribe and finish reading it all later
 

Duckinator

Member
Reputation
0
peelsaven is right about the long post but how can you do what you are talking about dor a mac
 
Top