Error occurred during http request {"data":"","status":0,"config":{"method":"GET","transformRequest":[null],"transformResponse":[null],"url":" 8&Culture=en-us","headers":{"Accept":"application/json, text/plain, */*"},"startTime":1446425245350},"statusText":""} HIMEM.SYS Memory Allocation Scheme

HIMEM.SYS Memory Allocation Scheme

This article has been archived. It is offered "as is" and will no longer be updated.
3.10 3.11
When you start your computer, HIMEM.SYS allocates all availableextended memory by default. It then manages the use of this memory byother applications with the extended memory specification (XMS).

How HIMEM.SYS Allocates Memory for Itself

HIMEM.SYS uses IBM ROM BIOS interrupt 15h to determine how muchextended memory is available. It then uses the same interrupt to setthe available extended memory to zero. This prevents otherapplications from allocating extended memory once HIMEM.SYS hasstarted managing memory. (If you run other programs that allocateextended memory by using interrupt 15h, use the /INT15= switch. Formore information, refer to the "User's Guide" for Windows 3.1.)

After setting the available extended memory to zero, HIMEM.SYS assignshandles to each free memory block. On a machine with 4 megabytes (MB)of random-access memory (RAM), the memory starting at 1 MB up to the4-MB boundary is usually contiguous. In this situation, HIMEM.SYSassigns only one handle to this memory block. More handles areassigned on machines with multiple memory blocks, such as Compaqmachines that have a small amount of memory starting at the 16-MBboundary.

Note: HIMEM.SYS does not allocate any memory until another programmakes an XMS function call. SMARTDrive and RAMDrive make XMS functioncalls when they are loaded. The "DOS=HIGH" statement in the CONFIG.SYSfile also makes an XMS call. This call requests the use of the highmemory area (HMA) and forces HIMEM.SYS to allocate extended memory.

How HIMEM.SYS Allocates Memory for Programs

HIMEM.SYS gives memory to programs that request it by making a call toan XMS function. It first looks for a large enough block to serve thememory request. Because some machines have more than one block, thereis no way to determine which block will be used first.

When HIMEM.SYS finds a large enough block of memory, it divides thememory block into two, which allows the program to use the memory itrequested and leave the remainder as a new smaller memory block. Thememory allocated to the program starts from the bottom of the blockand extends until the memory request is fulfilled. The new block,created from the extra memory, starts where the memory requeststopped.

Interrupt 15h Memory

Interrupt (or function) 15h always allocates memory starting from thetop of memory moving downwards. Before HIMEM.SYS starts, interrupt 15hsets the starting location or address of extended memory at the top orhighest extended memory address. When the amount of available extendedmemory lowers, the starting address also lowers. After HIMEM.SYSstarts, if no interrupt 15h memory was allocated, HIMEM.SYS sets thestarting address to the 1-MB boundary (the bottom of extended memory).

Interrupt 15h does not manage memory the same way that HIMEM.SYS does.Interrupt 15h is a large group of several functions for accessingextended memory. Programs actually take control of interrupt 15h byinserting a small piece of code into a table that tells the systemwhere interrupt 15h is located. This is known as creating a hook. Eachprogram that wants extended memory creates a hook and adds some codeto report how much memory is available. Programs report the initialavailable memory minus the amount they decided to use. HIMEM.SYS, whenit starts, is no different. It adds a hook that tells all otherprograms that no extended memory is left. HIMEM.SYS then doles outmemory to those programs that know how to use XMS functions, such asSMARTDrive, RAMDrive, and Windows.

Isolating Memory Areas with SMARTDRV.SYS and RAMDRIVE.SYS

By using SMARTDrive from Microsoft MS-DOS 5.0 and RAMDrive from eitherWindows or MS-DOS, you can roughly determine whether or not a block ofRAM is causing problems. This can be very useful for tracking downproblems such as memory parity errors.

Although the HIMEM.SYS memory allocation scheme does not allow you todetermine which memory it allocates at any given time, you can usefeatures of SMARTDrive and RAMDrive to perform a rough memory test.SMARTDrive allows you to create a cache limited only by the amount ofextended memory available. It also lets you set two sizes for thecache, one for MS-DOS and one for Windows. RAMDrive also allows you toallocate a large amount of extended memory, but it does not have thedual size capabilities of SMARTDrive.

By using SMARTDrive from MS-DOS 5.0, you can load SMARTDrive beforeRAMDrive in the CONFIG.SYS file. You can then tell SMARTDrive tocreate an MS-DOS cache size of some large amount of memory and aWindows cache size of zero. When you start Windows, SMARTDrive reducesits cache size to zero. Because RAMDrive installs after SMARTDrive,this leaves a gap of unused memory at the bottom, which enables you totest the lower half of extended memory. You can check the top half bysimply installing RAMDrive and nothing else.

To clarify this process, review the following step-by-step example,which explains what happens in extended memory as Windows and thevarious device drivers load. This example is for a machine with 4 MBof memory that is running MS-DOS 5.0 and Windows 3.1 and has frequentmemory parity errors:

  1. Add the following two lines, in the order given, to your CONFIG.SYS file:
    Check your AUTOEXEC.BAT file to ensure SMARTDrive is not being loaded from AUTOEXEC.BAT.
  2. Restart your computer. At this point, SMARTDrive occupies the lower two megabytes of extended memory, and RAMDrive occupies the upper two.
  3. Start Windows by typing win. SMARTDrive reduces its cache size to zero, leaving two megabytes free for Windows to use. RAMDrive still occupies the upper two megabytes of extended memory.
  4. Perform the steps necessary to reproduce the memory parity error. If you can reproduce the error, you can be fairly certain that the problem is in the lower two megabytes.
  5. Exit Windows and edit your CONFIG.SYS file again. This time, remove the SMARTDrive statement.
  6. Restart your computer. Now RAMDrive occupies the lower two megabytes of extended memory, and Windows can use the remainder.
  7. Again, go through the steps to reproduce the memory parity error. If you cannot reproduce the error, the problem is probably in the lower two megabytes of extended memory.
To narrow down the memory range, you can manipulate the SMARTDrivesettings so that you can determine a more accurate memory range andrepeat these steps. In the case of a memory parity error, you can thensimply replace the memory causing the error.
3.10 3.11

Article ID: 91088 - Last Review: 01/12/2015 15:47:06 - Revision: 3.0

  • kbnosurvey kbarchive KB91088