Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ memory.calc() — Micro Focus COBOL 4.0.5

Media Vault

Software Library

Restoration Projects

Artifacts Sought

                      Memory Usage and Micro Focus COBOL

  Trying to determine the amount of memory needed to run your Micro Focus
  COBOL applications can be very difficult. This is highly dependent on the
  type of application that you are running.

  There are two ways to approach this. First, try and estimate memory usage
  and second, measure actual memory usage.

  Estimating memory usage is *very* difficult. It used to be relatively easy
  when all that existed was static linking. You simply did a "size" command
  on the executable, got the size of the text portion and total data portion
  then did:
           mem = textsize + (users * datasize) to get an estimate.

  With int/gnt code, these are dynamically allocated and are not reported in
  the size command. If you are estimating, you need to add the code/data
  size numbers reported from the checker/generator and add these to the data
  segment.

  For example here are figures from compiling tictac.cbl with Micro Focus
  COBOL revision 3.2:

  >* Micro Focus COBOL for UNIX         V3.2 revision 043 Compiler
  >* Copyright (C) 1984-1994 Micro Focus Ltd.     URN 2XCLY/ZZ0/00000C
  >* Accepted - verbose
  >* Accepted - nolist
  >* Compiling tictac.cbl
  >* Total Messages:     0
  >* Data:        2532     Code:        1313
  >* Micro Focus COBOL for Unix         V3.2 revision 043 Code generator
  >* Copyright (C) 1984-1994 Micro Focus Ltd.     URN 2XCLY/ZZ0/00000C
  >* Accepted - verbose
  >* Generating tictac.int
  >* Data:        2704     Code:        2928     Literals:         960

  So, for estimating memory usage of this program, you would use:

  mem = textsize + ( users * initdatasize ) + (users * ( pidata + picode) )

  This would need to be done for *each* program that the application could
  load.

  With the addition of shared objects, you would need to calculate the size
  of each individual shared object, text & data sizes and do the same sort
  of calculation.

  Needless to say, this is all very time consuming and error prone.

  What we would recommend is analyzing actual memory usage for 2 or 3 users
  and then projecting for more. The easiest way we have found of reporting
  memory is 'sar -r'.  This reports free memory and swap space.

  So, what we would do is:

  1) Start a 'sar -r 5 1000' or something similar. This prints out free
  memory every 5 seconds 1000 times.  It's best to be on as lightly loaded a
  system as possible.

  2) Once the sar has stabalized, add the free memory & free swap to get a
  figure for your total free virtual memory.

  3) Have one user start the application to be measured and load up a
  typical usage scenario.

  4) Measure the total free virtual memory in sar
  5) Have another user start up (same idea as 3)

  6) Measure the total free virtual memory in sar

  7) Repeat if possible for 3 and 4 users

  At the end of this you should have a series of free memory figures.
  Subtracting them should give you the amount of memory that each user
  requires.

  As an example, we would expect to see the first user require 5 MB of RAM,
  the 2nd 2MB, the 3rd 2MB, the 4th 2MB, etc. Basically, a higher than
  normal figure for the first user as they need to load all the shared text
  & shared objects - the additional users will just make use of the existing
  shared code.

  So, the magic formula in this case would be:

    mem = 5MB + (users-1)*2MB

  Again, remember that the amount of memory needed is dependent on your
  system and your application. These formulas should be used as a guide.

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026