Use your COBOL configuration file to indicate which programs you want to share code. By default, no programs share code. To use shared code for all of your programs, add the following line to the configuration file:
SHARED_CODE 1
This causes all programs to attempt to share code. Every code segment loaded into memory is placed into shared memory until the shared memory area becomes full. If the system runs out of shared memory and the shared code requests start failing, each runtime will have its own copy of the program in its own memory space. The UNIX default for SHARED_CODE is 0 (no programs share code).
Because shared memory is a limited resource under UNIX and Linux, you will probably want to restrict the use of shared code to those programs that render the most benefit. This ensures that other programs do not unnecessarily use up the available shared memory. To do this, specify in your runtime configuration file each program that you want to share as follows:
SHARED_CODE Program1 SHARED_CODE Program2 SHARED_CODE Program3
(The program name may also be enclosed in single or double quotes, for example, Program1 or Program2.) When you are using this method, Program1, Program2, and so forth, specify the PROGRAM-IDs from the programs' Identification Division (note that a program's object file name is not used). If you use this method, setting SHARED_CODE to 1 has no effect.
To maximize the benefits of code sharing, begin by restricting the use of shared code to large programs that have many users. Later, if you find that you have enough shared memory in your system, you can extend its use to small programs that have many users. Use acushare's reporting facility to help you optimize the use of shared memory.