home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / lang / rexx / 1307 < prev    next >
Encoding:
Text File  |  1992-11-08  |  7.5 KB  |  184 lines

  1. Newsgroups: comp.lang.rexx
  2. Path: sparky!uunet!ftpbox!mothost!schbbs!waccvm.corp.mot.com!ACUS02
  3. From: ACUS02@waccvm.corp.mot.com (David McAnally)
  4. Subject: Re: Bug in CMS 6 - 'XEDIT' - Insuff. memory - Awk!
  5. Organization: Motorola
  6. Date: 6 Nov 1992 21:26:54 MST
  7. Message-ID: <1992Nov7.044852.19987@schbbs.mot.com>
  8. Sender: news@schbbs.mot.com (Net News)
  9. Nntp-Posting-Host: waccvm.corp.mot.com
  10. Lines: 172
  11.  
  12. >------------------------- Original Article -------------------------
  13. >From: tgtchb@tb3.chem.tue.nl (Harold C.L. Baur)
  14. >
  15. >Hi there,
  16. >
  17. >I am not sure wether this is the right place to post this to, but for
  18. >the heck of it, here it is:
  19. >
  20. >I am one of 5 people maintaining a multi user dungeon adventure, which is
  21. >written in Rexx. Lately, we noticed the game frequently crashed due to
  22. >insufficient memory. This somehow seemed related to some routines used to
  23. >back up and edit player stats. The way we change the datafiles is (I think)
  24. >a common one: by QUEUEing Xedit commands, and calling the 'XEDIT' from the
  25. >game at runtime. Now, what we THINK is that after leaving the editor, the
  26. >memory allocated to load it (and/or the files to be edited), is not released.
  27. >After a couple (many) of these calls to the XEDITor, the parent process (the
  28. >game) crashes *sniff*... OK. Anybody any clue/comment/idea on this?
  29. >
  30. >Virtually,
  31. >           Haribo - God of coding and editing in MUDA.
  32. >
  33. >
  34.  
  35. Here's one mehod of obtaining the approximate virtual memory available to
  36. REXX.  Call it as an external function (ie. mem=MEMORY() ).  It ain't the
  37. desired way, but if the system won't tell you....
  38.  
  39. Regards,
  40. David McAnally
  41. Specialist, Computer Applications
  42.  
  43.  Motorola
  44.  MCS Applications Engineering
  45.  MD R3148                             Internet: acus02@waccvm.corp.mot.com
  46.  8220 East Roosevelt Road             IBM IINMAIL ID: USMOTWTT
  47.  Scottsdale AZ 85257                  NeXT Mail:  acus02@ems13.corp.mot.com
  48.  
  49.  
  50. /* REXXCOMP: SLINE NOPR */
  51. /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  52. /* 11/06/92 Version 1.1 - MEMORY EXEC                                  */
  53. /* Originally written/provided by John Yoakum.                         */
  54. /* Modified by David McAnally - Motorola                               */
  55. /*                                                                     */
  56. /* REXX consumptive memory analysis for VM/CMS.                        */
  57. /* Reports approximate available/free virtual memory                   */
  58. /* by consuming a known "bite" of memory repetatively until storage    */
  59. /* is exausted, resulting in a REXX error.  A SIGNAL condition catches */
  60. /* this and goes to a subroutine where the available memory exhausted  */
  61. /* is caculated.   This isn't meant to be real acurate, but can be     */
  62. /* used to estimate available free memory for REXX programs.           */
  63. /* What else can one do if VM/CMS or REXX functions don't tell you?    */
  64. /* I use it sometimes in a REXX XEDIT macro to estimate if I have      */
  65. /* enough free memory to load a file and perform other processes.      */
  66. /*                                                                     */
  67. /* I recommend compiling with IBM REXX Compiler to save system         */
  68. /* resources and time.  This isn't the cheapest method of getting      */
  69. /* this information.                                                   */
  70. /*                                                                     */
  71. /* Results can be returned as a function, in the stack or on the       */
  72. /* screen.                                                             */
  73. /*                                                                     */
  74. /* Command:                                                            */
  75. /*                                                                     */
  76. /* MEMORY fork appetite ( options                                      */
  77. /*                                                                     */
  78. /* where:                                                              */
  79. /*                                                                     */
  80. /*   fork = kbytes to eat per iteration.Defaults to 10 (10K)           */
  81. /*   appetite = iterations to eat memory. Defaults to GLUTTON or all.  */
  82. /*   options = STACK                                                   */
  83. /*                                                                     */
  84. /* Examples:                                                           */
  85. /*                                                                     */
  86. /*   EXEC MEMORY                                                       */
  87. /*                                                                     */
  88. /*   (in a REXX exec)                                                  */
  89. /*                                                                     */
  90. /*   avail_memory = memory()                                           */
  91. /*                                                                     */
  92. /* Additional Notes:                                                   */
  93. /*                                                                     */
  94. /*   We have seen memory exahustion on WAKEUP servers and other        */
  95. /*   applications that run for an extended period of time (days).      */
  96. /*   It is a good idea to LOGOFF/LOGON or IPL these server apps        */
  97. /*   periodically to avoid virtual memory problems like this.          */
  98. /*                                                                     */
  99. /*   Things that can free up virtual memory include HX, EXECDROP and   */
  100. /*   NUCXDROP.                                                         */
  101. /*                                                                     */
  102. /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  103.   Parse Source . calltype .
  104.   rc = 0
  105.   i = 0
  106.   x = 0
  107.   knife = 1024                       /* default Kbyte size             */
  108.   spoon = 10                         /* default Morsel size            */
  109. /* lets get started                                                    */
  110.   parse upper arg fork appetite . '(' option .
  111.   if datatype(fork,w) ^= 1
  112.     then
  113.     fork = spoon
  114.   if datatype(appetite,w) ^= 1
  115.     then
  116.     do
  117.       appetite = 'GLUTTON'
  118.       aunit = ''
  119.     end
  120.   else
  121.     aunit = 'K'
  122. /* set error traps for when memory is exhausted                        */
  123.   SIGNAL ON FAILURE NAME FAILURE
  124.   SIGNAL ON ERROR NAME ERROR
  125.   SIGNAL ON HALT  NAME HALT
  126.   SIGNAL ON SYNTAX NAME SYNTAX
  127. /* consume memory                                                      */
  128.   bite = fork*knife
  129.   food = copies('*',bite)
  130.   if datatype(appetite,w) = 1
  131.     then
  132.     do i = 1 to appetite
  133.       eat.i = copies('*',bite)
  134.     end i
  135.   else
  136.     do i = 1 to 999999
  137.       eat.i = copies('*',bite)
  138.     end i
  139.   select
  140.     when option = 'STACK'
  141.       then
  142.       push fork*i 'K Free Storage available.'
  143.     when calltype='FUNCTION' Then nop
  144.     otherwise
  145.       do
  146.         say ' '
  147.         say 'Requested' appetite||aunit 'Free Storage available.'
  148.         say ' '
  149.       end
  150.   end
  151.   exit rc
  152. /* diagnose errors                                                     */
  153. ERROR:
  154.   nop
  155. HALT:
  156.   nop
  157. FAILURE:
  158.   nop
  159. SYNTAX:
  160.   drop eat.
  161.   if rc = 5
  162.     then
  163.     do
  164.       select
  165.         when calltype='FUNCTION' Then return fork*i
  166.         when option = 'STACK'
  167.           then
  168.           push fork*i 'K Free Storage available.'
  169.         otherwise
  170.           do
  171.             say ' '
  172.             say fork*i||'K Free Storage available.'
  173.             say ' '
  174.           end
  175.       end
  176.       exit 0
  177.     end
  178.   else
  179.     do
  180.       say 'REXX error' rc 'in line' sigl ':' errortext(rc)
  181.       exit rc
  182.     end
  183.   return
  184.