Text Device Mode
As with most text editors, when a text file is opened in the viewfile window, the entire file is loaded from disk and retained in memory. This is referred to as LoadAll mode. In this mode, the viewfile window continues to display the file content even if the file is deleted from the disk. However, as the file size increases, the initial read-in time and memory requirements also increase, leading to reduced performance. In such cases, you can use Sparse mode, as follows:
(hiSetViewfile win "./largeFile.txt" 'Sparse)
When a file is opened in Sparse mode, only minimal data is read from disk initially. More data is paged from disk and the old data is discarded from memory as required. For example, during a search operation or when scrolling. As a result, the viewfile window opens instantly, and exhibits better performance and reduced memory usage. However, unlike LoadAll mode, the file must remain on disk when using Sparse mode. If the file is removed, a warning message is displayed and the viewfile window is closed when attempting to page more data.
Because Sparse mode retains minimal data in memory, only a limited amount of data can be copied to the clipboard. Without this limit, the Select All—Copy operation would page the entire file contents in order to populate the copy buffer, resulting in an unexpected delay for large files. Therefore, the Copy operation is automatically disabled as soon as the data selection exceeds the default size limit of 100000 characters. However, you can modify the limit by using the maximumCopySize environment variable in the .cdsenv file.
Return to top