User Tools

Site Tools


rpg:display_memory_usage

Display Memory Usage

Displays the used heap memory from the various heaps.

     /**
      * \brief Display Memory Usage
      *
      * Displays the memory usage of a job grouped by
      * activation group.
      *
      * If no parameter is passed the memory of the current job
      * will be displayed.
      *
      * \author Mihael Schmidt
      * \date   11.02.2008
      */
 
      /copy QCPYSRC,RPGHEADER
 
      *---------------------------------------------------------------
      * PEP
      *---------------------------------------------------------------
     D main            PR                  extpgm('DSPMEM')
     D   job                         26A   const options(*nopass)
     D main            PI
     D   job                         26A   const options(*nopass)
 
 
      *---------------------------------------------------------------
      * Prototypen
      *---------------------------------------------------------------
     D getActivationGroupAttr...
     D                 PR                  extpgm('QWVOLAGP')
     D  receiver                  65535A   options(*varsize)
     D  recLength                    10I 0 const
     D  listInfo                     80A
     D  numberRecords                10I 0 const
     D  format                        8A   const
     D  job                          26A   const
     D  intJobId                     16A   const
     D  error                              likeds(apiErrDs) options(*varsize)
      *
     D closeList       PR                  extpgm( 'QGYCLST' )
     D   listHandle                   4A
     D   error                       10I 0
 
      *---------------------------------------------------------------
      * Data Structures
      *---------------------------------------------------------------
     D raga0100        DS                  qualified
     D  actGroupName                 10A
     D  reserved1                     6A
     D  actGroupNumber...
     D                               10I 0
     D  numberActGroups...
     D                               10I 0
     D  numberHeaps                  10I 0
     D  staticSize                   10I 0
     D  heapSize                     10I 0
     D  rootPgmName                  10A
     D  rootPgmLib                   10A
     D  rootPgmType                   1A
     D  actGroupState                 1A
     D  shrActGroupInd...
     D                                1A
     D  inUse                         1A
     D  reserved2                     4A
     D  actGroupNumberLong...
     D                               20I 0
     D  reserved3                     8A
      *
     D listInfoDs      DS                  qualified
     D   listTotal                   10I 0
     D   listReturned                10I 0
     D   listHandle                   4A
     D   listRecLen                  10I 0
     D   listComplete                 1A
     D   listDate                    13A
     D   listStatus                   1A
     D                                1A
     D   listLength                  10I 0
     D   listFirst                   10I 0
     D                               40A
 
      /copy QCPYSRC,API_ERR_H
 
 
      *---------------------------------------------------------------
      * Variablen
      *---------------------------------------------------------------
     D receiver        S          65355A
     D formatPtr       S               *
     D format          DS                  likeds(raga0100) based(formatPtr)
     D listInfo        DS                  likeds(listInfoDs)
     D i               S             10I 0
     D intRetVal       S             10I 0
      /free
       getActivationGroupAttr( receiver :
                               %len(receiver) :
                               listInfo :
                               %len(receiver) / %size(raga0100) :
                               'RAGA0100' :
                               '*' :
                               '' :
                               apiErrDs);
       if (apiErrCode = *blank);
         // check if list is finished
         // todo
 
         for i = 0 to listInfo.listReturned - 1;
           formatPtr = %addr(receiver) + (i * listInfo.listRecLen);
           dsply %trimr(format.actGroupname + ' ' +
                 %char(format.staticSize) + ' / ' +
                 %char(format.heapSize) +
                 '(' + %char(format.numberHeaps) + ')');
         endfor;
 
 
         // close list
         closeList(listInfo.listHandle : intRetVal);
 
       else;
         dsply apiErrCode;
       endif;
 
       *inlr = *on;
       return;
      /end-free
rpg/display_memory_usage.txt · Last modified: 2013/06/20 07:00 (external edit)