Defining a Memory-Based File

To define a Memory-Based file, set its File Type to MKY (memory, keyed) and do not set the External File flag. The file is defined in a similar way to a standard PROISAM in every other respect.

This is achieved by defining a database name in the Alternate Filename field with the name enclosed in percentage signs in its File Definition. Pair this with an entry for the file in the pro4v[n].ini file. Optionally an overriding block size may be defined for a given Memory-Based File.

[Database – alternate-file-name]

FILETYPE=MEMORY

BLOCKSIZE=blocksize

Block Size

To assist in tuning a system for best memory usage and/or speed, you can use a parameter called BLOCKSIZE on a per-memory-based file basis. The block size is used to specify the initial amount of memory (in bytes) allocated to the file. When that allocation is used up, additional blocks of memory (of that same size) is acquired from the operating system. For optimal space usage, the block size should be close to a multiple of the record size for optimal space usage. If BLOCKSIZE is not specified, the default value is the size required to hold one thousand records.

Memory-Based Files as Sortfiles

Memory-Based Files can be used for sorting by defining entries in the [Database – SORTFILE] section of a pro4v[n].ini file. FILETYPE must be set to MEMORY. The section format is:

[Database - SORTFILE]

FILETYPE=MEMORY

BLOCKSIZE=8192

System Resources

As these files reside in virtual memory, system administrators and PROIV developers need to be aware that additional virtual memory may need to be configured (possibly on both a per-process as well as a per-system basis) before extensive use is made of this feature. PROIV developers should ensure that memory files are cleared when they are no longer needed, in order that memory can be reused. In addition, an operating system or the user’s environment may place a limit on the size of memory-based files. PROIV application code should be written to trap such errors.

Comment on this topic

Topic ID: 720293