home *** CD-ROM | disk | FTP | other *** search
/ PC Format 22 / Disk22.iso / UTILS1.ZIP / PMAP.DOC < prev    next >
Text File  |  1987-05-10  |  19KB  |  432 lines

  1.  
  2.                                    PMAP 1.26
  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.
  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.      |      pmap [proglist]      (display memory usage)
  20.      |      pmap [proglist] /d   (display detailed memory usage)
  21.             pmap /r              (display raw memory allocation chain)
  22.  
  23.  
  24.         Standard display
  25.         ----------------
  26.  
  27.         When PMAP is invoked without parameters, you'll see a display
  28.         like this:
  29.  
  30.          Addr  Program    Parent   Parameters    Blks    Size    Vectors
  31.          ----  -------   --------  -----------   ----   -------  -------
  32.          1470  command   command                    2      3632  22 23 24 2E
  33.          155C  rxintmgr  command                    2      1408  60
  34.          15B6  sdump     command                    2      2816  05
  35.          1666  kbfix2    command   /KT1 /D0...      2      2560  08 09 16
  36.          1708  fastvr    command                    2       576
  37.          172E  ced       command   ??               2     26976  1B 61
  38.          1DC6  raw       command   ??               2       688
  39.          1DF4  cache-em  command   /1312 /t         2     28848  13 19 21
  40.          Total conventional free memory             1    503888
  41.          Extended memory installed                       393216
  42.          Largest conventional free block                 503888
  43.          Next program will load at 2500
  44.  
  45.         Each program that is currently in memory is displayed.  Fields
  46.         are as follows:
  47.  
  48.             Addr        The memory segment at which the program is
  49.                         loaded, in hexadecimal.
  50.  
  51.             Program     The name of the program, if available.  "??"
  52.                         indicates that the name is not available.  The
  53.                         program name is never available under DOS 2.x.
  54.  
  55.             Parent      The name of the program's "parent".  In most
  56.                         cases, this will be "command", because most
  57.                         programs are run by COMMAND.COM (i.e., from
  58.                         the DOS prompt).  See below.
  59.  
  60.             Parameters  The command line parameters that were specified
  61.                         when the program was run.  Some programs re-use
  62.                         the area where the parameters are stored, in
  63.                         which case a "??" will be displayed.  An
  64.                         ellipsis ("...") at the end indicates that there
  65.                         were more parameters than could fit here.
  66.  
  67.             Blocks      The number of memory blocks that are owned by
  68.                         the program.
  69.  
  70.             Size        The total size of all blocks owned by the
  71.                         program.
  72.  
  73.  
  74.             Vectors     A list of 80x8x interrupt vectors that appear to
  75.                         have been "intercepted" by the program.
  76.  
  77.         For example, the program KBFIX2 is loaded at memory segment
  78.         1666H and was run directly from the DOS prompt.  The original
  79.         parameters were "/KT1 /D0" and there were more parameters than
  80.         can be shown here.  DOS has allocated two blocks of memory for
  81.         the program, and they total 2560 bytes in size.  Vectors 8
  82.         (timer tick), 9 (keyboard interrupt), and 16 (keyboard service)
  83.         have been "intercepted" by KBFIX2.
  84.  
  85.         At the end of the list, PMAP indicates the number of blocks of
  86.         free memory, the total size of all free blocks, the largest
  87.         single free block, and the segment address at which the next
  88.         program will probably load.
  89.  
  90.      |  The amount of extended memory (AT memory above the 1 megabyte
  91.      |  mark) is displayed only if such memory is present.
  92.      |
  93.      |  You can restrict the display to certain programs by naming them
  94.      |  on the command line.  For example,
  95.      |
  96.      |      pmap sdump ced
  97.      |
  98.      |  would display information for the SDUMP and CED programs, and no
  99.      |  others.  The summary and expanded memory information is always
  100.      |  displayed.
  101.  
  102.         NOTE: "below" the first program loaded in memory (usually
  103.         COMMAND.COM), there is a block of memory allocated by DOS for
  104.         device drivers, etc.  PMAP does not show this block in its
  105.         standard display.  If you are interested to see how large it is
  106.         and where it is allocated, use the /R display described below,
  107.         in which it will be the first block listed; it will usually show
  108.         0008 in the "owner" field.
  109.  
  110.  
  111.         Detail display
  112.         --------------
  113.  
  114.         When you run PMAP with the /D (Detail) parameter, you'll see the
  115.         same display, except that PMAP will show a detailed list of
  116.         memory blocks allocated for each program.  For example:
  117.  
  118.          Addr  Program    Parent     Parameters  Blks    Size    Vectors
  119.          ----  -------   --------  ------------------   -------  -------
  120.          1666  kbfix2    command   /KT1 /D0...      2      2560  08 09 16
  121.          1661  Environment                                   64
  122.          1666  Program                                     2496
  123.  
  124.         KBFIX2 has two memory blocks allocated to it; PMAP shows the
  125.         size of each block and its address, and makes an educated guess
  126.         as to what the block is used for.
  127.  
  128.      |  You may include a list of specific programs to be displayed:
  129.      |
  130.      |      pmap sdump ced /d
  131.  
  132.         PMAP also displays a detail list of all free blocks of memory.
  133.  
  134.  
  135.         Raw display
  136.         -----------
  137.  
  138.         When you run PMAP with the /r (Raw) parameter, you'll see a
  139.         display like this:
  140.  
  141.             T  MCB  Addr  Owner  Para    Bytes
  142.             - ----  ----  -----  ----  --------
  143.             M 0974  0975   0008  0AFA     44960
  144.             M 146F  1470   1470  00C3      3120
  145.             M 1533  1534   1470  0020       512
  146.                [more of the same]
  147.             M 1DF3  1DF4   1DF4  0706     28768
  148.             M 24FA  24FB   2500  0004        64 [pmap]
  149.             M 24FF  2500   2500  1376     79712 [pmap]
  150.             Z 3876  3877   0000  6789    424080
  151.  
  152.         This is an uninterpreted list of all blocks of memory allocated
  153.         by DOS (see below).  The fields are as follows:
  154.  
  155.             Type        The block type.  There are only two block types,
  156.                         type M and type Z.  The last block in the
  157.                         chain is type Z, and all others are type M.
  158.  
  159.             MCB         The segment address of the Memory Control Block
  160.                         (sometimes known as an arena header).
  161.  
  162.             Addr        The segment address of the memory block itself.
  163.                         This is always equal to the MCB address plus
  164.                         one.
  165.  
  166.             Owner       The segment address of the program that "owns"
  167.                         the block of memory.  If this is 0000, the block
  168.                         is unallocated or "free".
  169.  
  170.             Para        The size of the block, in paragraphs (16 bytes).
  171.  
  172.             Bytes       The size of the block, in bytes.
  173.  
  174.         All numbers are hexadecimal except "bytes", which is decimal.
  175.  
  176.         The [pmap] suffix after an allocated block indicates that the
  177.         block is being used by PMAP.  When PMAP terminates, this block
  178.         will be free (unallocated).  The standard (non-Raw) PMAP display
  179.         understands this, and displays the map as if PMAP weren't there.
  180.  
  181.      |  If the /R switch is included, all other command line parameters
  182.      |  are ignored.
  183.  
  184.  
  185.         Expanded memory display
  186.         -----------------------
  187.  
  188.         If expanded (LIM-EMS, or EEMS) memory is present, PMAP always
  189.         displays EMS allocation as follows:
  190.  
  191.                     Expanded memory summary:
  192.  
  193.                     Block      Size
  194.                     -----    -------
  195.                     0          98304
  196.                     1        1409024
  197.                     Free           0
  198.                     Total    1507328
  199.                     Page frame segment: CC00h
  200.  
  201.         Like standard DOS memory, EMS memory is allocated in blocks.
  202.         However, no information is easily available regarding the blocks
  203.         except their sizes, so that is all that is displayed.
  204.  
  205.         EMS memory uses a "page frame" that maps a 64K block (actually,
  206.         four 16K "pages") of EMS memory into standard 80x8x memory.
  207.         The segment to which this memory is mapped is also displayed.
  208.  
  209.  
  210.         Interrupt vectors
  211.         -----------------
  212.  
  213.         Many times interrupts are "intercepted" by more than one
  214.         resident program.  PMAP will only show a vector attached to the
  215.         LAST program that intercepted it.  For example, KBFIX2 shows
  216.         that it has intercepted vectors 8, 9, and 16.  However, RXINTMGR
  217.         and SDUMP could also have intercepted any or all of these three
  218.         vectors, and PMAP would not know about that.
  219.  
  220.         PMAP assumes that any vector that points into memory owned by a
  221.         program has been intercepted by that program.  That is not
  222.         always true, so you may occasionally see spurious vectors
  223.         attached to a program.
  224.  
  225.  
  226.         More about parents
  227.         ------------------
  228.  
  229.         Every program has a "parent"; if program B was executed by
  230.         program A, then A is B's parent.  In most cases, the parent will
  231.         be COMMAND.COM, because most PC programs are executed by
  232.         COMMAND.COM.
  233.  
  234.         However, any program can execute any other program (assuming
  235.         that there is sufficient memory, etc.).  This is how "shells"
  236.         work.  For example, current versions of WordPerfect and many
  237.         other programs allow you to "exit to DOS"; what they usually do
  238.         is execute COMMAND.COM, which then displays a DOS prompt and
  239.         allows you to enter any commands that you wish.  If you run
  240.         PMAP, you will see two copies of COMMAND.COM in memory.
  241.  
  242.         However, you may notice that the second copy of COMMAND.COM
  243.         shows COMMAND.COM as its parent.  Logically, you would expect
  244.         the parent to be (in this case) WordPerfect.  Unfortunately,
  245.         some versions of COMMAND.COM (the one that comes with DOS 3.2,
  246.         for example) fool around with the area of memory that PMAP uses
  247.         to find the parent's address; rather than having the parent's
  248.         address, COMMAND.COM puts its own address there.  In effect,
  249.         COMMAND.COM is always its own parent.
  250.  
  251.         In general, programs that allow you to execute other programs
  252.         can use one of two methods: they can execute the other programs
  253.         directly, or the can execute COMMAND.COM and ask it to run the
  254.         requested program.  If the former, PMAP will show the true
  255.         parent; if the latter, PMAP will show COMMAND.COM, and
  256.         COMMAND.COM will be its own parent.
  257.  
  258.         Here is part of a PMAP display that shows a direct-execution
  259.         under DOS 3.2:
  260.  
  261.             Addr  Program    Parent   Blks    Size    Vectors
  262.             ----  -------   --------  ----   -------  -------
  263.             ...
  264.             3222  xced      command      2     26016
  265.             387E  qe        xced         3     97232
  266.             503E  command   command      3      3488  22 23 24
  267.             ...
  268.  
  269.         The XCED program was run by COMMAND.COM (from the DOS prompt).
  270.         It then ran the program QE directly, i.e., without reloading
  271.         COMMAND.COM.  Finally, a "shell" exit was taken from QE, which
  272.         did reload COMMAND.COM; notice that COMMAND shows as its own
  273.         parent.
  274.  
  275.  
  276.         Multi-tasking/task-switching programs
  277.         -------------------------------------
  278.  
  279.         ... play havoc with the memory allocation chain.  PMAP may
  280.         not yield very much useful information under such programs.
  281.  
  282.  
  283.         DOS's memory allocation chain
  284.         -----------------------------
  285.  
  286.         This information is almost totally undocumented by Microsoft, so
  287.         take it for what's it's worth.  It's provided for informational
  288.         purposes only, and could vary from DOS version to DOS version.
  289.  
  290.         DOS (version 2.00 or later) manages memory as a chain of
  291.         "blocks".  Each block begins on a paragraph boundary, can be (in
  292.         theory) almost a megabyte in size, and is preceded immediately
  293.         by a 16-byte Memory Control Block (MCB), sometimes known as an
  294.         "arena header".  The lowest (the 80x8x interrupt vectors, BIOS
  295.         and DOS data areas, DOS itself, device drivers, etc.) and
  296.         highest (video buffers, ROM modules) portions of memory are not
  297.         mapped, but the rest of memory is.  Thus, memory can be pictured
  298.         like this:
  299.  
  300.             paragraph   contents
  301.             ---------
  302.               0000      low memory (unmapped)
  303.                         first MCB (16 bytes)
  304.                         first memory block
  305.                         next MCB
  306.                         next memory block
  307.                         ...
  308.                         last MCB
  309.                         last memory allocation block
  310.               nnnn      end of DOS memory (640K, for example)
  311.  
  312.         The address of the first MCB will vary, depending on your
  313.         version of DOS, and the number and size of device drivers,
  314.         buffers, stacks, etc., that you loaded via CONFIG.SYS.  In all
  315.         current versions of DOS (through 3.21), the segment address of
  316.         the first MCB can be obtained via DOS function 52H.  On return
  317.         from this function, the address of the first MCB is located at
  318.         ES:[BX-2].  Here is sample code that returns the address of the
  319.         first MCB in AX:
  320.  
  321.             mov ah,52H
  322.             int 21H
  323.             mov ax,es:[bx-2]
  324.  
  325.         The MCB itself is a 16-byte region of memory that with fields as
  326.         follows:
  327.  
  328.             Offset  Size    Contents
  329.             ------  ----    --------
  330.             0       Byte    'M': this is not the last MCB
  331.                             'Z': this is the last MCB
  332.                             anything else: memory control blocks
  333.                             destroyed.  DOS will politely crash.
  334.  
  335.             1       Word    The segment address of the program that owns
  336.                             this block of memory (the program's PSP).
  337.  
  338.             3       Word    The size of the block, in paragraphs
  339.  
  340.             5-15            Reserved
  341.  
  342.         This structure provides all of the information needed to step
  343.         through the memory allocation chain.  A basic algorithm is as
  344.         follows:
  345.  
  346.             Set MCB = segment of first MCB (as described above)
  347.             Do Until byte (MCB:0) = 'Z'
  348.                 If byte (MCB:0) isn't 'M' or 'Z',
  349.                     Then there's a big problem
  350.                 Block_owner = word (MCB:1)
  351.                 Block_size = word (MCB:3)
  352.                 MCB = MCB + block_size + 1
  353.             End
  354.  
  355.         EMS and EEMS memory is not, of course, mapped by DOS.
  356.  
  357.         For more complete detail about DOS's memory allocation, see
  358.         "Managing Memory" by William J. Redmond in PC Tech Journal,
  359.         August, 1984 (Vol. 2, No. 2).
  360.  
  361.  
  362.         Version 1.26
  363.         ------------
  364.         Corrects a problem detecting extended memory with certain 
  365.         versions of BIOS ROM.
  366.  
  367.  
  368.         Version 1.25
  369.         ------------
  370.         Adds the extended memory display and the selective display
  371.         option.
  372.  
  373.         Corrects a minor problem with DOS 3.3.
  374.  
  375.  
  376.         Version 1.21
  377.         ------------
  378.         Bug fixes to version 1.20:
  379.  
  380.         1. No more runaway display when EMS memory is present but none
  381.         of it is in use.
  382.  
  383.         2. PMAP is more careful about what it thinks is the name of the
  384.         command shell.
  385.  
  386.  
  387.         Copyright/License/Warranty
  388.         --------------------------
  389.  
  390.         This document and the program file PMAP.EXE ("the software") are
  391.         copyrighted by the author.  The copyright owner hereby licenses
  392.         you to: use the software; make as many copies of the program and
  393.         documentation as you wish; give such copies to anyone; and
  394.         distribute the software and documentation via electronic means.
  395.         There is no charge for any of the above.
  396.  
  397.         However, you are specifically prohibited from charging, or
  398.         requesting donations, for any such copies, however made; and
  399.         from distributing the software and/or documentation with
  400.         commercial products without prior permission.  An exception is
  401.         granted to not-for-profit user's groups, which are authorized to
  402.         charge a small fee (not to exceed $7) for materials, handling,
  403.         postage, and general overhead.  NO FOR-PROFIT ORGANIZATION IS
  404.         AUTHORIZED TO CHARGE ANY AMOUNT FOR DISTRIBUTION OF COPIES OF
  405.         THE SOFTWARE OR DOCUMENTATION, OR TO INCLUDE COPIES OF THE
  406.         SOFTWARE OR DOCUMENTATION WITH SALES OF THEIR OWN PRODUCTS.
  407.  
  408.         THIS INCLUDES A SPECIFIC PROHIBITION AGAINST FOR-PROFIT
  409.         ORGANIZATIONS DISTRIBUTING THE SOFTWARE, EITHER ALONE OR WITH
  410.         OTHER SOFTWARE, AND CHARGING A "HANDLING" OR "MATERIALS" FEE OR
  411.         ANY OTHER SUCH FEE FOR THE DISTRIBUTION.  NO FOR-PROFIT
  412.         ORGANIZATION IS AUTHORIZED TO INCLUDE THE SOFTWARE ON ANY MEDIA
  413.         FOR WHICH MONEY IS CHARGED.  PERIOD.
  414.  
  415.         There is no restriction on the use of this software in
  416.         commercial or institutional environments.
  417.  
  418.         No copy of the software may be distributed or given away without
  419.         this document; and this notice must not be removed.
  420.  
  421.         There is no warranty of any kind, and the copyright owner is not
  422.         liable for damages of any kind.  By using this free software,
  423.         you agree to this.
  424.  
  425.         The software and documentation are:
  426.  
  427.                           Copyright (C) 1986, 1987 by
  428.                             Christopher J. Dunford
  429.                            10057-2 Windstream Drive
  430.                            Columbia, Maryland 21044
  431.                                 (301) 992-9371
  432.