home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PROGRAMS / UTILS / MEMORIA / MEMXD.ZIP / PMAP.DOC < prev    next >
Encoding:
Text File  |  1988-07-29  |  25.6 KB  |  599 lines

  1.  
  2.                                    PMAP 1.32
  3.                                    ---------
  4.  
  5.         PMAP (Program MAP) is a simple program that displays how your
  6.         PC's memory is being used.  It lists all active programs
  7.         (including resident programs such as Sidekick and PCED) and
  8.         tells you how much free memory is available for programs.  If
  9.         expanded (LIM) memory is present, a summary of EMS use is also
  10.         shown.  A list of installed devices is optionally displayed.
  11.  
  12.         | indicates new or changed features for the latest version of
  13.         PMAP.  See also version history below.
  14.  
  15.  
  16.         Syntax summary
  17.         --------------
  18.  
  19.         The command line syntax of PMAP is:
  20.  
  21.       |     pmap [/drsvx?] [program-list]
  22.  
  23.         The optional /switches are:
  24.  
  25.                 d   display Detail list of allocation by programs
  26.                 r   display Raw list of memory blocks
  27.       |         s   display only Standard DOS memory
  28.       |         v   display deVice driver information
  29.       |         x   display only eXpanded memory
  30.       |         ?   display syntax summary
  31.  
  32.         Program-list, if present, restricts the display to the listed
  33.         programs.  Named programs may contain wildcards (*).
  34.  
  35.         Examples:
  36.  
  37.           pmap            (default display)
  38.           pmap /r         (raw display)
  39.           pmap /d sdump   (detail display of program SDUMP only)
  40.           pmap sdump c*   (display SDUMP and anything beginning with C)
  41.           pmap /x         (display only expanded memory usage)
  42.           pmap /v         (display only device driver data)
  43.  
  44.  
  45.         Standard display
  46.         ----------------
  47.  
  48.         When PMAP is invoked without parameters, you'll see a display
  49.         similar to this:
  50.  
  51.  
  52.           Addr Program   Parent    Parameters     Han Blks   Size    Vectors
  53.           ---- -------  -------- ---------------  --- ----  -------  -------
  54.           147D command  command  main               0    2     3888  2E
  55.           157B nmi      command  /i/q               0    2     1856  02
  56.           15F2 cache-em command  500                0    2    13168  13 19
  57.           193E dbase    command  /C d:command      16    2   238384  30
  58.           ...
  59.           Total conventional free memory                 4   451696
  60.           Largest conventional free block                    371168
  61.           Extended memory installed                          425984
  62.           Next program will load at 5579
  63.  
  64.         Each program that is currently in memory is displayed.  Fields
  65.         are as follows:
  66.  
  67.             Addr        The memory segment at which the program is
  68.                         loaded, in hexadecimal.
  69.  
  70.             Program     The name of the program, if available.  "n/a"
  71.                         indicates that the name is not available.  The
  72.                         program name is never available under DOS 2.x.
  73.  
  74.             Parent      The name of the program's "parent".  In most
  75.                         cases, this will be "command", because most
  76.                         programs are run by COMMAND.COM (i.e., from
  77.                         the DOS prompt).  See below.
  78.  
  79.             Parameters  The command line parameters that were specified
  80.                         when the program was run.  Some programs re-use
  81.                         the area where the parameters are stored, in
  82.                         which case a "??" will be displayed.  An
  83.                         ellipsis ("...") at the end indicates that there
  84.                         were more parameters than could fit here.
  85.  
  86.           | Han         The number of open handles (or files) associated
  87.           |             with the owner.  See below.
  88.  
  89.             Blocks      The number of memory blocks that are owned by
  90.                         the program.
  91.  
  92.             Size        The total size of all blocks owned by the
  93.                         program.
  94.  
  95.  
  96.             Vectors     A list of 80x8x interrupt vectors that appear to
  97.                         have been "intercepted" by the program.
  98.  
  99.         For example, the program NMI is loaded at memory segment 157BH
  100.         and was run directly from the DOS prompt or from a batch file.
  101.         The original parameters were "/i/q".  DOS has allocated two
  102.         blocks of memory for the program, and they total 1856 bytes in
  103.         size.  Vector 2 (nonmaskable interrupt) has been "intercepted"
  104.         by NMI.
  105.  
  106.         At the end of the list, PMAP indicates the number of blocks of
  107.         free memory, the total size of all free blocks, the largest
  108.         single free block, and the segment address at which the next
  109.         program will probably load.
  110.  
  111.         The amount of extended memory (AT memory above the 1 megabyte
  112.         mark) is displayed only if such memory is present.
  113.  
  114.         You can restrict the display to certain programs by naming them
  115.         on the command line.  For example,
  116.  
  117.             pmap sdump ced
  118.  
  119.         would display information for the SDUMP and CED programs, and no
  120.         others.  The summary and expanded memory information is always
  121.         displayed.
  122.  
  123.       | You can use a single wildcard '*' at the end of any named
  124.       | program in the list.  For example,
  125.       |
  126.       |     pmap sd* c*
  127.       |
  128.       | would display information for all programs beginning with
  129.       | "sd" or "c".
  130.  
  131.         NOTE: "below" the first program loaded in memory (usually
  132.         COMMAND.COM), there is a block of memory allocated by DOS for
  133.         device drivers, etc.  PMAP does not show this block in its
  134.         standard display.  If you are interested to see how large it is
  135.         and where it is allocated, use the /R display described below,
  136.         in which it will be the first block listed; it will usually show
  137.         0008 in the "owner" field.
  138.  
  139.  
  140.         Detail display
  141.         --------------
  142.  
  143.         When you run PMAP with the /D (Detail) parameter, you'll see the
  144.         same display, except that PMAP will show a detailed list of
  145.         memory blocks allocated for each program.  For example:
  146.  
  147.          Addr Program  Parent    Parameters  Han Blks  Size   Vectors
  148.          ---- ------- -------- ------------- --- ---- ------- -------
  149.          1666 kbfix2  command  /KT1 /D0...     0    2    2560 08 09 16
  150.          1661  Environment                                 64
  151.          1666  Program                                   2496
  152.  
  153.         KBFIX2 has two memory blocks allocated to it; PMAP shows the
  154.         size of each block and its address, and makes an educated guess
  155.         as to what the block is used for.
  156.  
  157.         You may include a list of specific programs to be displayed:
  158.  
  159.             pmap sdump ced /d
  160.  
  161.         PMAP also displays a detail list of all free blocks of memory.
  162.  
  163.  
  164.         Raw display
  165.         -----------
  166.  
  167.         When you run PMAP with the /r (Raw) parameter, you'll see a
  168.         display like this:
  169.  
  170.             T  MCB  Addr  Owner  Para    Bytes
  171.             - ----  ----  -----  ----  --------
  172.             M 0974  0975   0008  0AFA     44960
  173.             M 146F  1470   1470  00C3      3120
  174.             M 1533  1534   1470  0020       512
  175.                [more of the same]
  176.             M 1DF3  1DF4   1DF4  0706     28768
  177.             M 24FA  24FB   2500  0004        64 [pmap]
  178.             M 24FF  2500   2500  1376     79712 [pmap]
  179.             Z 3876  3877   0000  6789    424080
  180.  
  181.         This is an uninterpreted list of all blocks of memory allocated
  182.         by DOS (see below).  The fields are as follows:
  183.  
  184.             Type        The block type.  There are only two block types,
  185.                         type M and type Z.  The last block in the
  186.                         chain is type Z, and all others are type M.
  187.  
  188.             MCB         The segment address of the Memory Control Block
  189.                         (sometimes known as an arena header).
  190.  
  191.             Addr        The segment address of the memory block itself.
  192.                         This is always equal to the MCB address plus
  193.                         one.
  194.  
  195.             Owner       The segment address of the program that "owns"
  196.                         the block of memory.  If this is 0000, the block
  197.                         is unallocated or "free".
  198.  
  199.             Para        The size of the block, in paragraphs (16 bytes).
  200.  
  201.             Bytes       The size of the block, in bytes.
  202.  
  203.         All numbers are hexadecimal except "bytes", which is decimal.
  204.  
  205.         The [pmap] suffix after an allocated block indicates that the
  206.         block is being used by PMAP.  When PMAP terminates, this block
  207.         will be free (unallocated).  The standard (non-Raw) PMAP display
  208.         understands this, and displays the map as if PMAP weren't there.
  209.  
  210.         If the /R switch is included, all other command line parameters
  211.         are ignored.
  212.  
  213.  
  214.         Expanded memory display
  215.         -----------------------
  216.  
  217.         If expanded (LIM-EMS, or EEMS) memory is present, PMAP always
  218.         displays EMS allocation as follows:
  219.  
  220.             Expanded memory summary:
  221.  
  222.                     Block      Size    Name
  223.                     -----    -------   ----
  224.                     0         589824   SYSTEM
  225.                     1         425984
  226.                     2          16384   CDIR
  227.                     3          65536   HINDSITE
  228.                     ...
  229.                     Free      327680
  230.                     Total    2097152
  231.                     Page frame segment: CC00h
  232.  
  233.       | The NAME field will be present only if your expanded memory
  234.       | manager supports the LIM 4.0 specification, and then only for
  235.       | programs that have defined their names to the system.
  236.  
  237.         EMS memory uses a "page frame" that maps a 64K block (actually,
  238.         four 16K "pages") of EMS memory into standard 80x8x memory.
  239.         The segment to which this memory is mapped is also displayed.
  240.  
  241.         If you only want to display the expanded memory allocation, use
  242.         the /X switch.  To suppress the display of expanded memory, use
  243.         /S.
  244.  
  245.  
  246.       | Device driver display
  247.       | ---------------------
  248.       |
  249.       | If you execute PMAP with the /V switch, it will display a table
  250.       | of information about your installed device drivers.  No other
  251.       | data (i.e., no memory maps) are displayed when /V is selected.
  252.       |
  253.       | The first five columns of the table contain the following
  254.       | fields:
  255.       |
  256.       |     Name        If the device is a character device, the device
  257.       |                 name.  If it is a block device (like a disk),
  258.       |                 this will be "Blk (n)", where n is the number
  259.       |                 of units handled by this device.
  260.       |
  261.       |     Address     The address where the device driver begins in
  262.       |                 memory, in standard hex segment:offset form.
  263.       |
  264.       |     Size        The approximate size (in bytes, displayed in
  265.       |                 decimal) of the device driver.  See below.
  266.       |
  267.       |     Strt        The entry point of the driver's strategy
  268.       |                 routine.  This is the hex offset within the
  269.       |                 device driver's segment (shown under ADDRESS).
  270.       |
  271.       |     Intr        The entry point of the driver's interrupt
  272.       |                 routine.  This is the hex offset within the
  273.       |                 device driver's segment (shown under ADDRESS).
  274.       |
  275.       | The remaining columns are bit fields with the driver's attribute
  276.       | record.  In each case, an asterisk indicates that the bit is
  277.       | set (1), and a space indicates that it is reset (0).
  278.       |
  279.       |     CHR         *    = this is a character device
  280.       |                 <sp> = this is a block device.
  281.       |
  282.       |     IOC         *    = device supports IOCTL calls
  283.       |
  284.       |     IBM    for block devices:
  285.       |                 *    = non-IBM format
  286.       |            for character devices:
  287.       |                 *    = supports output-until-busy
  288.       |
  289.       |     RMV         *    = supports removable media
  290.       |
  291.       |     LOG         *    = supports Get/Set Logical Device
  292.       |
  293.       |     CLK         *    = this is the clock device
  294.       |
  295.       |     NUL         *    = this is the NUL device
  296.       |
  297.       |     SOT         *    = this is this standard output device
  298.       |
  299.       |     SIN    for block devices:
  300.       |                 *    = supports generic IOCTL
  301.       |            for character devices
  302.       |                 *    = this is the standard input device
  303.       |
  304.       | Note that <space> inplies the opposite of <*>; for example, an
  305.       | asterisk in IOC indicates that the device supports IOCTL calls,
  306.       | while a space there indicates that IOCTL is not supported.
  307.       |
  308.       | Also note that DOS does not provide any documented way for
  309.       | programs to find the chain of device drivers.  If PMAP is unable
  310.       | to find the chain, it will tell you so.
  311.  
  312.  
  313.       | Device driver size; order of list
  314.       | ---------------------------------
  315.       |
  316.       | PMAP cannot reliably determine the size of the default devices
  317.       | (CON, PRN, AUX, COM1, etc.) that are loaded automatically by
  318.       | DOS.  These will all show an address beginning with "0070", and
  319.       | their sizes will not be displayed.  However, if you load a
  320.       | replacement for one of these devices (for example, ANSI.SYS
  321.       | loads a replacement for CON), PMAP will generally be able to
  322.       | determine and display its size.
  323.       |
  324.       | PMAP cannot determine the size of the last device loaded by
  325.       | CONFIG.SYS.  If you wish to determine the size of the last
  326.       | device, and your CONFIG.SYS loads more than one device, you can
  327.       | determine its size by simply swapping the load order of the last
  328.       | two devices in CONFIG.SYS and rebooting.
  329.       |
  330.       | The devices are shown in the order in which DOS searches for
  331.       | them.  If there are two or more devices with the same name, the
  332.       | one that DOS will use is the first one listed.  For example, you
  333.       | will have two or more CON devices if you use ANSI.SYS; the
  334.       | ANSI.SYS CON will be listed before the default CON.  DOS will
  335.       | use the first one listed (ANSI.SYS).
  336.  
  337.  
  338.         Interrupt vectors
  339.         -----------------
  340.  
  341.         Many times interrupts are "intercepted" by more than one
  342.         resident program.  PMAP will only show a vector attached to the
  343.         LAST program that intercepted it.  For example, KBFIX2 shows
  344.         that it has intercepted vectors 8, 9, and 16.  However, RXINTMGR
  345.         and SDUMP could also have intercepted any or all of these three
  346.         vectors, and PMAP would not know about that.
  347.  
  348.         PMAP assumes that any vector that points into memory owned by a
  349.         program has been intercepted by that program.  That is not
  350.         always true, so you may occasionally see spurious vectors
  351.         attached to a program.
  352.  
  353.  
  354.         More about parents
  355.         ------------------
  356.  
  357.         Every program has a "parent"; if program B was executed by
  358.         program A, then A is B's parent.  In most cases, the parent will
  359.         be COMMAND.COM, because most PC programs are executed by
  360.         COMMAND.COM.
  361.  
  362.         However, any program can execute any other program (assuming
  363.         that there is sufficient memory, etc.).  This is how "shells"
  364.         work.  For example, current versions of WordPerfect and many
  365.         other programs allow you to "exit to DOS"; what they usually do
  366.         is execute COMMAND.COM, which then displays a DOS prompt and
  367.         allows you to enter any commands that you wish.  If you run
  368.         PMAP, you will see two copies of COMMAND.COM in memory.
  369.  
  370.         However, you may notice that the second copy of COMMAND.COM
  371.         shows COMMAND.COM as its parent.  Logically, you would expect
  372.         the parent to be (in this case) WordPerfect.  Unfortunately,
  373.         some versions of COMMAND.COM (the one that comes with DOS 3.2,
  374.         for example) fool around with the area of memory that PMAP uses
  375.         to find the parent's address; rather than having the parent's
  376.         address, COMMAND.COM puts its own address there.  In effect,
  377.         COMMAND.COM is always its own parent.
  378.  
  379.         In general, programs that allow you to execute other programs
  380.         can use one of two methods: they can execute the other programs
  381.         directly, or the can execute COMMAND.COM and ask it to run the
  382.         requested program.  If the former, PMAP will show the true
  383.         parent; if the latter, PMAP will show COMMAND.COM, and
  384.         COMMAND.COM will be its own parent.
  385.  
  386.         Here is part of a PMAP display that shows a direct-execution
  387.         under DOS 3.2:
  388.  
  389.             Addr  Program    Parent   Han  Blks    Size    Vectors
  390.             ----  -------   --------  ---  ----   -------  -------
  391.             ...
  392.             3222  xced      command     0     2     26016
  393.             387E  qe        xced        0     3     97232
  394.             503E  command   command     0     3      3488  22 23 24
  395.             ...
  396.  
  397.         The XCED program was run by COMMAND.COM (from the DOS prompt).
  398.         It then ran the program QE directly, i.e., without reloading
  399.         COMMAND.COM.  Finally, a "shell" exit was taken from QE, which
  400.         did reload COMMAND.COM; notice that COMMAND shows as its own
  401.         parent.
  402.  
  403.  
  404.       | File handles
  405.       | ------------
  406.       |
  407.       | The "Han" field of the standard memory display shows the number
  408.       | of file handles that are associated with each program.  For the
  409.       | most part, this field will be zero.  Some open handles may show
  410.       | for programs that are active (for example, the active program
  411.       | named "dbase" in the first example has 16 open files).
  412.       |
  413.       | You may see some resident programs that show one or more open
  414.       | handles.  This usually occurs when you redirect the program's
  415.       | start-up logo to NUL, and the program fails to close its
  416.       | standard files before exiting back to DOS (it really shouldn't
  417.       | be necessary, but it is).  These open handles may reduce the
  418.       | number of files your application programs can have
  419.       | simultaneously open.  We prefer not to redirect programs' logos
  420.       | to NUL.  We save file handles; we get to see the names of the
  421.       | nice people who wrote our software, and their copyrights; and we
  422.       | don't lose the error messages that explain why the program
  423.       | isn't doing what we thought it should.  Sounds like a bargain.
  424.  
  425.  
  426.         Multi-tasking/task-switching programs
  427.         -------------------------------------
  428.  
  429.         ... play havoc with the memory allocation chain.  PMAP may
  430.         not yield very much useful information under such programs.
  431.  
  432.  
  433.         DOS's memory allocation chain
  434.         -----------------------------
  435.  
  436.         This information is almost totally undocumented by Microsoft, so
  437.         take it for what's it's worth.  It's provided for informational
  438.         purposes only, and could vary from DOS version to DOS version.
  439.  
  440.         DOS (version 2.00 or later) manages memory as a chain of
  441.         "blocks".  Each block begins on a paragraph boundary, can be (in
  442.         theory) almost a megabyte in size, and is preceded immediately
  443.         by a 16-byte Memory Control Block (MCB), sometimes known as an
  444.         "arena header".  The lowest (the 80x8x interrupt vectors, BIOS
  445.         and DOS data areas, DOS itself, device drivers, etc.) and
  446.         highest (video buffers, ROM modules) portions of memory are not
  447.         mapped, but the rest of memory is.  Thus, memory can be pictured
  448.         like this:
  449.  
  450.             paragraph   contents
  451.             ---------
  452.               0000      low memory (unmapped)
  453.                         first MCB (16 bytes)
  454.                         first memory block
  455.                         next MCB
  456.                         next memory block
  457.                         ...
  458.                         last MCB
  459.                         last memory allocation block
  460.               nnnn      end of DOS memory (640K, for example)
  461.  
  462.         The address of the first MCB will vary, depending on your
  463.         version of DOS, and the number and size of device drivers,
  464.         buffers, stacks, etc., that you loaded via CONFIG.SYS.  In all
  465.         current versions of DOS (verified through 3.30), the segment
  466.         address of the first MCB can be obtained via DOS function 52H.
  467.         On return from this function, the address of the first MCB is
  468.         located at ES:[BX-2].  Here is sample code that returns the
  469.         address of the first MCB in AX:
  470.  
  471.             mov ah,52H
  472.             int 21H
  473.             mov ax,es:[bx-2]
  474.  
  475.         The MCB itself is a 16-byte region of memory that with fields as
  476.         follows:
  477.  
  478.             Offset  Size    Contents
  479.             ------  ----    --------
  480.             0       Byte    'M': this is not the last MCB
  481.                             'Z': this is the last MCB
  482.                             anything else: memory control blocks
  483.                             destroyed.  DOS will politely crash.
  484.  
  485.             1       Word    The segment address of the program that owns
  486.                             this block of memory (the program's PSP).
  487.  
  488.             3       Word    The size of the block, in paragraphs
  489.  
  490.             5-15            Reserved
  491.  
  492.         This structure provides all of the information needed to step
  493.         through the memory allocation chain.  A basic algorithm is as
  494.         follows:
  495.  
  496.             Set MCB = segment of first MCB (as described above)
  497.             Do Until byte (MCB:0) = 'Z'
  498.                 If byte (MCB:0) isn't 'M' or 'Z',
  499.                     Then there's a big problem, so abort
  500.                 Block_owner = word (MCB:1)
  501.                 Block_size = word (MCB:3)
  502.                 MCB = MCB + block_size + 1
  503.             End
  504.  
  505.         EMS and EEMS memory is not, of course, mapped by DOS.
  506.  
  507.         For more complete detail about DOS's memory allocation, see
  508.         "Managing Memory" by William J. Redmond in PC Tech Journal,
  509.         August, 1984 (Vol. 2, No. 2).
  510.  
  511.  
  512.         Version 1.31/1.32 (7/29/88)
  513.         -----------------
  514.         Displays number of open handles for each PSP.
  515.         Displays sizes of some devices (/V switch).
  516.         Improved display when too many vectors to fit on one line.
  517.         Fixed spurious errorlevel returned by successful run (32).
  518.  
  519.         Version 1.30
  520.         ------------
  521.         Adds /X, /S, and /? switches.
  522.         Adds device driver display (/V).
  523.         Displays names of EMS-users when available (LIM 4.0 only).
  524.         Allows wildcards in program-list.
  525.         Fixes problem with name of secondary copies of COMMAND.COM
  526.             under DOS 3.3 (it's not available).
  527.  
  528.         Version 1.26
  529.         ------------
  530.         Corrects a problem detecting extended memory with certain
  531.         versions of BIOS ROM.
  532.  
  533.         Version 1.25
  534.         ------------
  535.         Adds the extended memory display and the selective display
  536.         option.
  537.  
  538.         Corrects a minor problem with DOS 3.3.
  539.  
  540.         Version 1.21
  541.         ------------
  542.         Bug fixes to version 1.20:
  543.  
  544.         1. No more runaway display when EMS memory is present but none
  545.         of it is in use.
  546.  
  547.         2. PMAP is more careful about what it thinks is the name of the
  548.         command shell.
  549.  
  550.  
  551.         Copyright/License/Warranty
  552.         --------------------------
  553.  
  554.         This document and the program file PMAP.EXE ("the software") are
  555.         copyrighted by the author.  The copyright owner hereby licenses
  556.         you to: use the software; make as many copies of the program and
  557.         documentation as you wish; give such copies to anyone; and
  558.         distribute the software and documentation via electronic means.
  559.         There is no charge for any of the above.
  560.  
  561.         However, you are specifically prohibited from charging, or
  562.         requesting donations, for any such copies, however made; and
  563.         from distributing the software and/or documentation with
  564.         commercial products without prior permission.  An exception is
  565.         granted to not-for-profit user's groups, which are authorized to
  566.         charge a small fee (not to exceed $7) for materials, handling,
  567.         postage, and general overhead.  NO FOR-PROFIT ORGANIZATION IS
  568.         AUTHORIZED TO CHARGE ANY AMOUNT FOR DISTRIBUTION OF COPIES OF
  569.         THE SOFTWARE OR DOCUMENTATION, OR TO INCLUDE COPIES OF THE
  570.         SOFTWARE OR DOCUMENTATION WITH SALES OF THEIR OWN PRODUCTS.
  571.  
  572.         THIS INCLUDES A SPECIFIC PROHIBITION AGAINST FOR-PROFIT
  573.         ORGANIZATIONS DISTRIBUTING THE SOFTWARE, EITHER ALONE OR WITH
  574.         OTHER SOFTWARE, AND CHARGING A "HANDLING" OR "MATERIALS" FEE OR
  575.         ANY OTHER SUCH FEE FOR THE DISTRIBUTION.  NO FOR-PROFIT
  576.         ORGANIZATION IS AUTHORIZED TO INCLUDE THE SOFTWARE ON ANY MEDIA
  577.         FOR WHICH MONEY IS CHARGED.  PERIOD.
  578.  
  579.         There is no restriction on the use of this software in
  580.         commercial or institutional environments.
  581.  
  582.         No copy of the software may be distributed or given away without
  583.         this document; and this notice must not be removed.
  584.  
  585.         There is no warranty of any kind, and the copyright owner is not
  586.         liable for damages of any kind.  By using this free software,
  587.         you agree to this.
  588.  
  589.         The software and documentation are:
  590.  
  591.                        Copyright (C) 1986, 1987, 1988 by
  592.                             Christopher J. Dunford
  593.                             The Cove Software Group
  594.                                  P.O. Box 1072
  595.                            Columbia, Maryland 21044
  596.  
  597.                                 (301) 992-9371
  598.                         CompuServe 76703,2002 [IBMNET]
  599.