Function Memory() Foundation
Retrieves statistics about available memory.
Memory( <nMemoryID> ) --> nAvailableMemory
Constant | Return value |
---|---|
MEM_VIRT_AVAIL | Available virtual memory in kilobyte |
MEM_VIRT_TOTAL | Total size of virtual memory in kilobyte |
MEM_RAM_AVAIL | Available random access memory (RAM) in kilobyte |
MEM_RAM_TOTAL | Installed random access memory (RAM) in kilobyte |
MEM_PROC_AVAIL | Memory available for the process in kilobyte |
MEM_PROC_TOTAL | Total memory available for the process in kilobyte |
MEM_HANDLES_AVAIL | Available memory handles |
MEM_HANDLES_TOTAL | Total memory handles for the process |
MEM_HANDLES_USED | Memory handles used by the process |
The return value of Memory() depends on the argument <nMemoryID>.
The environment function Memory() determines an approximation of available memory. The return value of Memory() serves only as an indication of the available memory and should not be thought of as an exact figure of the memory currently available. Due to multitasking and multithreading these values might become obsolete right after retrieval. Memory() considers the main memory (RAM) as well as available virtual memory provided by the operating system. Virtual memory is typically allocated within a page file located on the hard drive. Furthermore, the function Memory() can be used to determine the memory available and currently in use by the process.
Finally, using the function Memory() the amount of memory handles can be determined. This applies to the total amount of memory available to the process and the amount of memory currently used by the process.
// The example calls the function Memory() and shows
// values that can be expected.
#include "os.ch"
PROCEDURE Main
? Memory(MEM_VIRT_AVAIL) // 197504 - Over 100MB of the virtual memory is used.
? Memory(MEM_VIRT_TOTAL) // 301268 - The pagefile size was set to 300MB.
? Memory(MEM_RAM_AVAIL) // 63520 - Almost half of the RAM is unused at the moment.
? Memory(MEM_RAM_TOTAL) // 130484 - The workstation is equipped with 128MB of RAM.
? Memory(MEM_PROC_TOTAL) // 58228 - 58MB of memory are available to the process
? Memory(MEM_PROC_TOTAL)-;
Memory(MEM_PROC_AVAIL) // 24102 - 24MB of memory are currently used by the process
? Memory(MEM_HANDLES_TOTAL) // 2000213 - Approx. 2 million memory handles are available
? Memory(MEM_HANDLES_USED) // 733 - 733 memory handles are currently in use
RETURN
If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.