Use memory files to reduce disk I/O during program execution. Memory files differ from the other file types only in that they are temporary files that reside in memory. You can write to and read from a memory file just as you do with a disk file.
You must specify the /Sv compiler option to use memory files.
You can create a memory file in two ways:
stream = fopen("memfile.txt", "w, type=memory");
stream=fopen("DD:MEMFILE", "w");
Before you run your application, use the set command. For example, the following command assigns the filename memfile.txt to the ddname MEMFILE.
SET DD:MEMFILE=memfile.txt, memory(y)
You must specify the /Sh compiler option to use ddnames.
Once a memory file has been created, it can be accessed by the module that created it as well as by any other function within the same process. The memory file remains accessible until the file is removed by the remove function or until the program has terminated.
You can request that the temporary files created by the tmpfile function be either disk files or memory files. By default, tmpfile creates disk files. To have temporary files created as memory files, set the TEMPMEM environment variable to ON:
SET TEMPMEM=on
The word "on" can be in any case. You must still specify the memoryfiles Language Option.
fopen("A.A","w,type=memory");
remove("a.a");
The above call to remove will not remove memory file A.A because the file name is in uppercase. Because memory files are always checked first, the function will look for memory file a.a, and if that file does not exist, it will remove the disk file a.a (or A.A, because disk files are not case sensitive).
![]()
Redirect Standard
Streams
Open Streams Using Data Definition Names