Interested in improving this site? Please check the To Do page.

Back to Sys Verbs

sys.memInfo

Provide detailed information on Frontier's memory use inside Windows. Primarily intended for pinpointing and diagnosing memory problems with Frontier. On the Macintosh, this verb functions identically to sys.memAvail(). On Windows, the verb provides much more information, as detailed below.

(programming in progress)

Syntax

sys.memInfo(memStatisticsType, returnInBytesType)

Params

sys.memInfo returns data in two forms: a long value representing one memory-related stat or a Frontier list containing all of the memory stats, normalized when appropriate into kilobytes. The memStatisticsType is an integer value that controls this operation.

When memStatisticsType is 0, it returns a Frontier list, containing memory data normalized as described below. Each item in the list is indicated by the index shown in the table below. The third item in the list, for example, would be the free bytes of physical memory in kilobytes.

When memStatisticsType is an integer above zero, it returns a single item of data corresponding to the list below. For example, if memStatisticsType is 3, the function returns free bytes of physical memory in total bytes, unless modified by returnInBytesType (see below).

Index Windows data returned Short description Returned individual
item size
Returned list
normalized size
0Returns a list containing normalized data in the following order
1 dwMemoryLoad percent of memory in use percentage percentage
2 dwTotalPhys total bytes of physical memory bytes Kbytes
3 dwAvailPhys free bytes of physical memory bytes Kbytes
4 dwTotalPageFile total bytes of paging file bytes Kbytes
5 dwAvailPageFile free bytes of paging file bytes Kbytes
6 dwTotalVirtual total bytes of virtual memory bytes Kbytes
7 dwAvailVirtual free bytes of virtual memory bytes Kbytes
8 ullTotalPhys total bytes of physical memory bytes Kbytes
9 ullAvailPhys free bytes of physical memory bytes Kbytes
10 ullTotalPageFile total bytes of paging file bytes Kbytes
11 ullAvailPageFile free bytes of paging file bytes Kbytes
12 ullTotalVirtual total bytes of virtual memory bytes Kbytes
13 ullAvailVirtual free bytes of virtual memory bytes Kbytes
14 ullAvailExtendedVirtual free bytes of extended memory bytes Kbytes
15 CommitTotal total committed pagesKbytes
16 CommitLimit current avail pagesKbytes
17 CommitPeak max committed pagesKbytes
18 PhysicalTotal actual physical memory pages Kbytes
19 PhysicalAvailable physical memory currently available pagesKbytes
20 SystemCache system cache memory pagesKbytes
21 KernelTotal page + non-paged pool pagesKbytes
22 KernelPaged paged kernel pool pagesKbytes
23 KernelNonpaged non-paged kernel pool pagesKbytes
24 PageSize size of a page bytes bytes
25 HandleCount number of open handles countcount
26 ProcessCount number of processes count count
27 ThreadCount number of threads count count

returnInBytesType is an integer value that controls how big the number is that is returned. dwTotalPageFile and other statistics can routinely report values in excess of 4 gigabytes, but the biggest number Frontier can handle is 2147483647. This is why the basic memAvail function often now returns unusable results. But returnInBytes type asks whether to return as bytes, kilobytes, or megabytes, reducing the size of the number that Frontier must handle.

  • 1 returns bytes
  • 2 returns kilobytes
  • 3 returns megabytes

returnInBytesType must be specified even if memStatisticsType is 0, returning a Frontier list. Even so, it is ignored (other than it still must be 1, 2, or 3).

Actions

Returns memory data as described.

Returns

A number or list corresponding to the data requested. Returns false if the parameters are incorrect.

Examples

The following example attempts to get the total bytes of the paging file, but the returned number is too large for Frontier to handle.

sys.memInfo(4,1)
> -165101568

By querying the same stat, but specifying kilobytes (via the 2 in the second parameter slot), the number is something Frontier can handle:

sys.memInfo(4,2)
> 4033072   (which means (4033072K)

By querying the same stat, but specifying megabytes (via the 3 in the second parameter slot), the number is also something Frontier can handle:

sys.memInfo(4,3)
> 3938   (which means (3938M)

To determine the number of bytes in the non-paged pool:

pages = sys.memInfo(23, 1)  // number of pages in the non-page pool
>> 25329
pageSize = sys.memInfo(24, 1)  // size of a page, in bytes
>> 4096
nonPagedPoolBytes = pages * pageSize // total non-paged pool, in bytes
>> 103747584
nonPagedPoolKBytes = nonPagedPoolBytes / 1024 // total non-paged pool, in Kbytes
>> 101316

To determine the total non-paged pool, in Kbytes, using the list option:

myList = sys.memInfo(0,1)
nonPagePoolKBytes = myList[23]
>> 101316

To just get a dump of all the memory data in one call:

myList = sys.memInfo(0,1)
>> {57, 2095580, 889272, 4033072, 2902796, 2097024, 2038896, 2095580, 
889272, 4033072, 2902796, 2097024, 2038896, 0, 1130288, 4033072, 1438856, 
2095580, 889272, 690316, 174416, 73100, 101316, 4096, 82404, 57, 773}

Errors

What could possibly go wrong?

Notes

This verb is new in Frontier 10.1a16. It is implemented only in the Windows version. If called on a Mac, it executes the exact same code as sys.memAvail and therefore is functionally identical.

dwAvailPageFile is the same as the basic Frontier memAvail() function. dwAvailVirtual is the same as the Frontier sys.memAvail() function.

This function provides information from both the MEMORYSTATUS and MEMORYSTATUSEX structures, even though both represent what seems to be identical data (except for the extended data of the EX structure). Even though this appears redundant, the purpose of this function is to expose as much internal memory data as possible, and so, rather than limiting the scope, it makes everything it can find available for advanced scripters and developers to use.

The MEMORYSTATUS structure

dwMemoryLoad: A number between 0 and 100 that specifies the approximate percentage of physical memory that is in use (0 indicates no memory use and 100 indicates full memory use).

dwTotalPhys: The amount of actual physical memory, in bytes.

dwAvailPhys: The amount of physical memory currently available, in bytes. This is the amount of physical memory that can be immediately reused without having to write its contents to disk first. It is the sum of the size of the standby, free, and zero lists.

dwTotalPageFile: The current size of the committed memory limit, in bytes. This is physical memory plus the size of the page file, minus a small overhead.

dwAvailPageFile: The maximum amount of memory the current process can commit, in bytes. This value should be smaller than the system-wide available commit.

dwTotalVirtual: The size of the user-mode portion of the virtual address space of the calling process, in bytes. This value depends on the type of process, the type of processor, and the configuration of the operating system. For example, this value is approximately 2 GB for most 32-bit processes on an x86 processor and approximately 3 GB for 32-bit processes that are large address aware running on a system with 4 GT RAM Tuning enabled.

dwAvailVirtual: The amount of unreserved and uncommitted memory currently in the user-mode portion of the virtual address space of the calling process, in bytes.

The MEMORYSTATUSEX structure

ullTotalPhys: The amount of actual physical memory, in bytes.

ullAvailPhys: The amount of physical memory currently available, in bytes. This is the amount of physical memory that can be immediately reused without having to write its contents to disk first. It is the sum of the size of the standby, free, and zero lists.

ullTotalPageFile: The current size of the committed memory limit, in bytes. This is physical memory plus the size of the page file, minus a small overhead.

ullAvailPageFile: The maximum amount of memory the current process can commit, in bytes. This value should be smaller than the system-wide available commit.

ullTotalVirtual: The size of the user-mode portion of the virtual address space of the calling process, in bytes. This value depends on the type of process, the type of processor, and the configuration of the operating system. For example, this value is approximately 2 GB for most 32-bit processes on an x86 processor and approximately 3 GB for 32-bit processes that are large address aware running on a system with 4-gigabyte tuning enabled.

ullAvailVirtual: The amount of unreserved and uncommitted memory currently in the user-mode portion of the virtual address space of the calling process, in bytes.

ullAvailExtendedVirtual: The amount of unreserved and uncommitted memory currently in the extended portion of the virtual address space of the calling process, in bytes.

The PERFORMANCE_INFORMATION structure

CommitTotal: The number of pages currently committed by the system. Note that committing pages (using the Windows call VirtualAlloc with MEM_COMMIT) changes this value immediately; however, the physical memory is not charged until the pages are accessed.

CommitLimit: The current maximum number of pages that can be committed by the system without extending the paging file(s). This number can change if memory is added or deleted, or if pagefiles have grown, shrunk, or been added. If the paging file can be extended, this is a soft limit.

CommitPeak: The maximum number of pages that were simultaneously in the committed state since the last system reboot.

PhysicalTotal: The amount of actual physical memory, in pages.

PhysicalAvailable: The amount of physical memory currently available, in pages. This is the amount of physical memory that can be immediately reused without having to write its contents to disk first. It is the sum of the size of the standby, free, and zero lists.

SystemCache: The amount of system cache memory, in pages. This is the size of the standby list plus the system working set.

KernelTotal: The sum of the memory currently in the paged and nonpaged kernel pools, in pages.

KernelPaged: The memory currently in the paged kernel pool, in pages.

KernelNonpaged: The memory currently in the nonpaged kernel pool, in pages.

PageSize: The size of a page, in bytes.

HandleCount: The current number of open handles.

ProcessCount: The current number of processes.

ThreadCount: The current number of threads.


Personal Tools