Virtual memory files are allocated whenever malloc starts returning NULL. In that case, a new empty file is created on disk with the size rounded up to the next multiple of the memory page size. This file is memory-mapped in public mode, which signals the OS that memory associated to this mapping can be safely dumped to disk at any moment. The mapped pointer is returned to the caller of the allocator.
To avoid name clashes, VM files should all have different names. The current naming scheme is using a base name (vmswap_) and concatenates it to the process ID and to a registration number assigned internally by the module. This allows to run several processes making use of VM files simultaneously. Since there cannot be two processes running with the same PID, the name prefix for a process is unique at any given moment.
The file registration number is simply an integer which is incremented for each newly created VM file.
The VM file name is necessary to delete the file when it is deallocated, but the whole file name does not need to be stored in the memory cells. Since the naming scheme for VM files is constant for a given version of the module, it is enough to remember only the file registration number (VM file ID) and build up the file name from it when necessary.
It might be judged necessary to change the VM file naming scheme at some later stage, so programs using the module should never rely on the scheme itself, only on VM file IDs.
VM files are created in a temporary area, which should be large enough to fit the memory requirements. Setting up an automated system to find a suitable place is out of the scope of this module. The default directory used to store VM files is '.' (the current directory). This can be changed at any moment by using xmemory_settmpdir() and read by using xmemory_gettmpdir() (see module reference below).